I have the following type of XML: -
我有以下类型的XML: -
<tagCategory name="Bike" id="10">
</tagCategory>
<tagCategory name="Cars" id="22">
<excludedClass>NonDriver</excludedClass>
<excludedClass>BannedFromDriving</excludedClass>
</tagCategory>
<tagCategory name="PogoStick" id="5">
<excludedClass>NoLegs</excludedClass>
</tagCategory>
I want to run queries where I can say: -
我想在我可以说的地方运行查询: -
Give me all the tagCategory elements where the excludedClass isn't X. For example: -
给我所有的excludedClass不是X的tagCategory元素。例如: -
- Give me all the tagCategory elements where the excludedClass isn't 'NoLegs' should return Cars and Bike.
- Give me all the tagCategory elements where the excludedClass isn't 'BannedFromDriving' should return Bike and PogoStick.
- Give me all the tagCategory elements where the excludedClass isn't 'NonDriver' should return Bike and PogoStick.
给我所有的exceptClass不是'NoLegs'的tagCategory元素应该返回Cars和Bike。
给我所有tagCategory元素,其中excludedClass不是'BannedFromDriving'应返回Bike和PogoStick。
给我所有的exceptClass不是'NonDriver'的tagCategory元素应该返回Bike和PogoStick。
I'm using the current XPath and it handles the elements with only one excludedClass but where multiple are present it doesn't filter the items out as I'd expect.
我正在使用当前的XPath,它只使用一个excludedClass处理元素,但是存在多个,它不会像我期望的那样过滤掉项目。
"//tagCategory[excludedClass!='" + classification + "' or not(excludedClass)]"
“// tagCategory [excludedClass!='”+ classification +“'or not(excludedClass)]”
Does anyone have any ideas how I can modify my XPath to give me what I need?
有没有人有任何想法如何修改我的XPath给我我需要的东西?
Really appreciate any ideas.
真的很感激任何想法。
Kind regards,
Phil.
1 个解决方案
#1
0
Try using something like:
尝试使用类似的东西:
//tagCategory[not(excludedClass='NonDriver')]
example:
//tagCategory[not(excludedClass='" + classification + "')]
#1
0
Try using something like:
尝试使用类似的东西:
//tagCategory[not(excludedClass='NonDriver')]
example:
//tagCategory[not(excludedClass='" + classification + "')]