Xml 如何使用Xpath 1.0比较多个属性对?
目标是只选择那些Xml 如何使用Xpath 1.0比较多个属性对?,xml,xpath,Xml,Xpath,目标是只选择那些 具有具有子节点的同级节点,该子节点的属性值与需要选择的节点的属性值匹配 //*[(@attribute1 = ./following-sibling::*/@attribute2) or (@attribute1 = ./preceding-sibling::*/@attribute2)] --- sibling node with another attribute 具有具有属性值与需要选择的节点的另一个属性值匹配
//*[(@attribute1 = ./following-sibling::*/@attribute2)
or
(@attribute1 = ./preceding-sibling::*/@attribute2)]
--- sibling node with another attribute
//*[(@attribute1 = ./following-sibling::*/@attribute2)
or
(@attribute1 = ./preceding-sibling::*/@attribute2)]
--- sibling node with another attribute
我可以理解为什么像下面这样的Xpath表达式不会选择我要查找的节点集:
//first/second[@attr1=parent::first/second/third/@attrx][@attr2=parent::first/second[@attry]
是否可以选择我要查找的节点集?如果可以,如何选择?这些是否适用于您 具有同级节点和具有属性的子节点的节点 与需要选择的节点的属性值匹配的值:
//*[(@attribute = ./following-sibling::*/*/@attribute)
or
(@attribute = ./preceding-sibling::*/*/@attribute)]
--- sibling node --- ------------
|
child node with a same attribute
节点有一个同级节点,其属性值与
需要选择的节点的另一个属性值
//*[(@attribute1 = ./following-sibling::*/@attribute2)
or
(@attribute1 = ./preceding-sibling::*/@attribute2)]
--- sibling node with another attribute