Reputation: 8058
I am trying to use a conditional to filter some nodes of the following XML using xpath.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE html>
<html>
<body>
<div class="video_wrapper">
<div class="stretchy-wrapper">
<video width="1280px" height="720px">
<source src="video-480p.mp4" type="video/mp4" label="480P" res="480"/>
<source src="video-720p.mp4" type="video/mp4" label="720P" res="720"/>
<source src="video.mp4" type="video/mp4" label="1080P" res="1080"/>
</video>
</div>
</div>
</body>
</html>
This XPath works:
xmllint --xpath "//source" ./scratch.xml
<source src="video-480p.mp4" type="video/mp4" label="480P" res="480"/>
<source src="video-720p.mp4" type="video/mp4" label="720P" res="720"/>
<source src="video.mp4" type="video/mp4" label="1080P" res="1080"/>
However this does not:
xmllint --xpath "//source[@res='1000']" ./scratch.xml
XPath set is empty
Is my syntax somehow wrong?
P.S. The version of libxml on my system is 20904
Upvotes: 0
Views: 366
Reputation: 111541
//source[@res='1000']
selects nothing because your document has no such source
element.
Perhaps you meant
//source[@res='1080']
^
which selects
<source src="video.mp4" type="video/mp4" label="1080P" res="1080"/>
Upvotes: 1