【发布时间】:2021-01-16 06:03:30
【问题描述】:
我正在尝试使用条件来使用 xpath 过滤以下 XML 的某些节点。
<?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>
此 XPath 有效:
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"/>
但事实并非如此:
xmllint --xpath "//source[@res='1000']" ./scratch.xml
XPath set is empty
我的语法有什么错误吗?
附:我系统上的libxml版本是20904
【问题讨论】: