XPath for attribute in parent not containing a specific character?
确定父节点是否不包含特定字符的XPath表达式是什么?
给定以下XML:
1 2 3 4 5 6 7 8 9 10 | <root> <parent id="parent_1" attr="ABC"> <child id="child_11"/> <child id="child_12"/> </parent> <parent id="parent_2" attr="XYZ"> <child id="child_21"/> <child id="child_22"/> </parent> </root> |
XPath表达式将如何测试哪些子代的父代在其属性
作为ID为
这个XPath
1 | //child[not(contains(../@attr,"Y"))] |
将选择所有没有父元素且其
1 2 | <child id="child_11"/> <child id="child_12"/> |
按照要求。