在xml中使用xpath中的前一项表示唯一/不同的项
我想返回唯一项目的列表。在这种情况下,它应该返回 项目1 项目2 我尝试过以下方法:在xml中使用xpath中的前一项表示唯一/不同的项,xml,xpath,Xml,Xpath,我想返回唯一项目的列表。在这种情况下,它应该返回 项目1 项目2 我尝试过以下方法: //Item/Group/Name[not(text()=preceding::Item/Group/Name)]/text() //Item/Group/Name[not(text()=preceding::Item/Group/Name/text())]/text() //Item/Group[not(Name/text()=preceding::Item/Group/Name/text())]/Name/
//Item/Group/Name[not(text()=preceding::Item/Group/Name)]/text()
//Item/Group/Name[not(text()=preceding::Item/Group/Name/text())]/text()
//Item/Group[not(Name/text()=preceding::Item/Group/Name/text())]/Name/text()
就是不能让它工作
<List>
<Item>
<Group>
<Name>Item 1</Name>
</Group>
</Item>
<Item>
<Group>
<Name>Item 1</Name>
</Group>
</Item>
<Item>
<Group>
<Name>Item 2</Name>
</Group>
</Item>
</List>
项目1
项目1
项目2
应该做这项工作的:
//List/Item/Group/Name[not(preceding::*/Name/text() = text())]/text()
它将返回所有的“项目”名称,前面没有重复
编辑:我不确定我是否正确理解了您的问题,因为现在我意识到您的解决方案似乎也能工作…是的,结果是我使用的在线xpath测试工具无法工作。啊!非常感谢。