0

I have simple XML file like that:

<screen>
    <object attribute="String"/>
    <object attribute="Relationship">
         <vertices>
             <vertex point_index="1" x="18" y="30" />
             <vertex point_index="2" x="91" y="30" />
             <vertex point_index="3" x="91" y="60" />
             <vertex point_index="4" x="18" y="60" />                   
         </vertices>
    </object>
</screen>

How to correctly use XPath(1.0) count() function to receive vertices count in object with specified type? I'm trying to use the following string, but online XPath test tool (http://www.xpathtester.com/test) returns error.

count(/screen/object[@attribute="Relationship"]/vertices/*)

What seems to be wrong?

1
  • 1
    vard, You may be interested to try the XPath Visualizer -- an open source and non-commercial tool written by me. During the years the XPath Visualizer has helped thousands of people learn XPath the fun way. huttar.net/dimitre/XPV/TopXML-XPV.html Commented Dec 4, 2012 at 13:45

1 Answer 1

2

There is nothing wrong with the XPath. It is just that the testing tool you are using is not able to return number as result. Try this testing tool instead: http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, your tool said it's correct. Seems like most online XPath test tools aren't able to parse same XPath.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.