Results 1 to 2 of 2
  1. #1
    Juuno is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default dynamically parse xpath predicates

    XPathExpression expr = xpath.compile("//catalog//book[title='Midnight Rain']//author//text()");

    In the above code, the result will be the author node value in which the tile is 'Midnight Rain', right? But I would like to parse that value dynamically from user input instead of constant value. Like, for example: XPathExpression expr = xpath.compile("//catalog//book[title=input-got-from-user]//author//text()");

    How can i do this? Thanks in advance.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    have tried getting input from the user, use this input to create a String via concatenation (or use a StringBuilder for the same), then xpath.compile this newly created String? If I'm being too simplistic regarding your problem, sorry. I think that XPath is the next best thing to sliced bread for simplifying the task of rummaging through XML files. Best of luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts