Reputation: 1990
I have this XML :
<Parent>
<Children name='RandomValueIdontKnow'>
<x>1</x>
<x>2</x>
<x>3</x>
<x>4</x>
</Children>
</Parent>
I want to get Children
's name
attribute value AND all x
's values in one query
What i tried so far .. :
xpath("Children/@name|x");
but it only comes up with the name
attribute value and ignores x
's values ..
I tried to remove Parent
from the xml and do this query :
xpath("@name|x"); //grabs name's attribute value and all of the x's values
it worked fine, for some reason it stops when there's a parent or something.. that's kinda confusing me
Upvotes: 0
Views: 816
Reputation: 70460
x
aren't rootnodes, so you'll have to repeat Children
:
"Children/@name|Children/x"
Upvotes: 1
Reputation: 52858
For XPath 1.0, try:
(/*/Children/@name|/*/Children/x)
For XPath 2.0, try:
/*/Children/(@name|x)
Upvotes: 1