how to select an element based on order and depends on its existence in XPath? For example, how to choose the best quality video if it exists.
<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 does not exist
this case may exist (video names may 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 exists. Many thanks.
source
share