1

For example: I want to find the keywords without node id="year", and return "Train":

<r>
<keywords>
    <node id="family" keyref="Transport"></node>
    <node id="product" keyref="Car"></node>
    <node id="year" keyref="2017"></node>
</keywords>

<keywords>
    <node id="family" keyref="Transport"></node> 
    <node id="product" keyref="Train"></node>       <- FIND THIS
</keywords>

<keywords>
    <node id="family" keyref="Transport"></node>
    <node id="product" keyref="Bike"></node>
    <node id="year" keyref="2017"></node>
</keywords>
</r>
kjhughes
  • 106,133
  • 27
  • 181
  • 240
Zoe
  • 21
  • 3
  • 1
    Possible duplicate of [XPath to select Element by attribute value](https://stackoverflow.com/questions/14248063/xpath-to-select-element-by-attribute-value) – Andersson Aug 01 '18 at 11:47

1 Answers1

1

This XPath,

//node[not(@id="year")]

will select all node elements that do not have a @id="year" attribute value. You can append /@keyref if you only want the keyref attribute.


This XPath,

//keywords[not(node/@id="year")]

will select all keywords elements that do not have a node child element with @id="year".

kjhughes
  • 106,133
  • 27
  • 181
  • 240