Xpath that evaluates -all- attributes?

Posted by Tres on Stack Overflow See other posts from Stack Overflow or by Tres
Published on 2010-06-07T22:52:00Z Indexed on 2010/06/08 0:12 UTC
Read the original article Hit count: 563

Filed under:
|

I maybe be trying to do something invalid here, but maybe someone smarter than me knows the correct syntax to solve my problem. Given:


    <group code="vehicle">
        <line code="car">
            <cell>
                <box code="price">1000.00</box>
            </cell>
        </line>
        <line code="car">
            <cell code="sports">
                <box code="price">500.00</box>
            </cell>
        </line>
    </group>
If I use //*[@code="vehicle"]//*[@code="car"]//*[@code="price"], I will get both boxes returned (1000.00 and 500.00)--as expected but not what I want.

Is there an xpath syntax that will evaluate against all nodes that have an attribute of @code rather than skipping it if it doesn't match with the end result being that I only get back the first box (price of 1000.00)? Like asking, choose the first node with @code and that @code must equal "vehicle", then choose the next node with @code and that @code must equal "car", then choose the next node with @code and @code must equal "price".

© Stack Overflow or respective owner

Related posts about xpath

Related posts about attributes