Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于这个简单的 XML 文档,
<root> <mode value="foo" icon="billing.png" /> <mode value="bar" /> </root>
我如何选择@value 和@icon,但前提是@icon 存在?我知道我能做到
/root/mode/@value | /root/mode/@icon
但这仍然选择了 foo。
利用:
/root/mode[@value and @icon]/@value | /root/mode[@value and @icon]/@icon
尝试以下操作:
/root/mode/[string(@icon)]