如何在 XPath 中使用一个表达式从同一个节点中选择两个属性? [英] How to select two attributes from the same node with one expression in XPath?
本文介绍了如何在 XPath 中使用一个表达式从同一个节点中选择两个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
//person[@id='abc123']/@haircolor|/@weight"
PS.有很多人"记录
推荐答案
试试这个:
//person[@id='abc123']/@*[name()='weight' or name()='haircolor']
如果您使用的是 XPath 2.0 处理器,您还可以使用更漂亮的选项:
If you're using an XPath 2.0 processor, you may also use a prettier option:
//person[@id='abc123']/(@haircolor|@weight)`
这篇关于如何在 XPath 中使用一个表达式从同一个节点中选择两个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文