I am testing some xpath expresions using http://ift.tt/1i4Ssa3
I have this xml code
<urls>
<url uri="http://ift.tt/14uee2R">
<elements>
<element title="header" xpath="My header"></element>
</elements>
</url>
<url uri="http://ift.tt/1uhnn77">
<elements>
<element title="header3" xpath="Third header"/>
<element title="header2" xpath="Second header"/>
</elements>
</url>
</urls>
Usually when I query xpath with //element/@title I get
Attribute='title="header"' Attribute='title="header3"' Attribute='title="header2"'
What I'm looking for is a way to get a count of elements by url. It could be something like this. When I query:
//urls/url/elements/count(element)
I get
Double='1.0' Double='2.0'
Is there a way to do this in a single xpath expression?
Some failing examples:
This returns the count of all element 3 (is not what I'm looking for)
count(//urls/url/elements/element)
This returns the count of all elements list 2 (neither what I'm looking for)
count(//urls/url/elements)
I need this because I need to know how many elements does the xml have for each url, so I can use this count afterwards
No comments:
Post a Comment