Xpath how to select an element based on an order and dependent of its existence

Posted by hokkos on Stack Overflow See other posts from Stack Overflow or by hokkos
Published on 2010-04-05T03:10:05Z Indexed on 2010/04/05 3:13 UTC
Read the original article Hit count: 323

Filed under:
|

Hi, how to select an element based on an order and dependent of its existence in XPath ? For example how to select the best quality video if it exist.

<VIDEOS>
    <LOW_RES>video_L.flv</LOW_RES>
    <HI_RES>video_H.flv</HI_RES>
    <HD/>
</VIDEOS>

this should return video_H.flv because the hd version doesn't exist

this case can exist (the videos names can be random):

<VIDEOS>
    <LOW_RES>video_L.flv</LOW_RES>
    <HI_RES>video_H.flv</HI_RES>
    <HD>video_hd.mp4</HD>
</VIDEOS>

this should return video_hd.mp4 because the hd version exist. Many thanks.

© Stack Overflow or respective owner

Related posts about xpath

Related posts about Xml