1
我有以下XML:XPath選擇沒有具有特定值的子節點的XML節點?
<?xml version="1.0" encoding="UTF-8"?>
<targets>
<target sanctions-set-id="4387" ssid="5762">
<individual>
<identity ssid="5764" main="true">
<name ssid="27036" name-type="primary-name">
<value>SomeName1</value>
</name>
</identity>
</individual>
<modification modification-type="de-listed" enactment-date="2016-02-29" publication-date="2016-03-01" effective-date="2016-03-01"/>
<modification modification-type="amended" enactment-date="2015-11-17" publication-date="2015-11-18" effective-date="2015-11-18"/>
<modification modification-type="amended" enactment-date="2014-11-27" publication-date="2014-11-28" effective-date="2014-11-28"/>
<modification modification-type="amended" enactment-date="2013-12-18" publication-date="2013-12-19" effective-date="2013-12-20"/>
<modification modification-type="listed"/>
</target>
<target sanctions-set-id="4388" ssid="5763">
<individual>
<identity ssid="5765" main="true">
<name ssid="27037" name-type="primary-name">
<value>SomeName2</value>
</name>
</identity>
</individual>
<modification modification-type="amended" enactment-date="2015-11-17" publication-date="2015-11-18" effective-date="2015-11-18"/>
<modification modification-type="amended" enactment-date="2014-11-27" publication-date="2014-11-28" effective-date="2014-11-28"/>
<modification modification-type="amended" enactment-date="2013-12-18" publication-date="2013-12-19" effective-date="2013-12-20"/>
<modification modification-type="listed"/>
</target>
</targets>
,我需要選擇不具有修飾型摘牌的子節點的任何目標節點。換句話說,我的xpath應該只返回SomeName2的第二個目標,因爲沒有被刪除的修改類型。
這是我所能得到的最接近的,但它仍然選擇兩者。
targets/target[modification[@modification-type != 'de-listed']]
正是我所需要的。謝謝。 –