• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid XPath expression while trying to parse a path with attribute in DOM parser.

 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've a xml file as follow.


Now I wanna to get the parent attribute for the corresponding name attribute(which was input from user). I'm using the selectSingleNode() method of dom parser and I've given the xpath as "//sources/source/[@name='PropertySetter']", which leads the Invalidpath exception. Please find the java code below.



I got the exception as below.
org.dom4j.InvalidXPathException: Invalid XPath expression: //sources/source/[@name ='PropertySetter' Expected one of '.', '..', '@', '*', <QName>....

Suggestion please...
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
g tsuji
Ranch Hand
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Now I wanna to get the parent attribute for the corresponding name attribute
If I interprete it correctly, the xpath I would use would be this.

Use such as getText() would give you directly the attribute parent's setting.
 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:

it works thank you...
 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
g tsuji wrote:>Now I wanna to get the parent attribute for the corresponding name attribute
If I interprete it correctly, the xpath I would use would be this.

Use such as getText() would give you directly the attribute parent's setting.

awesome :D
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic