1

I am looking to fetch a node which has an empty element.

below is my xml

<sys>
   <platform>
      <contact>
        <name>company</name>
        <LVN>test</LVN>
        <address></address>
        <phone>12345</phone>
        <pager/>
    </contact>
  </platform>
</sys>

I am using the below query /sys/platform/contact[./address/text()='' and ./LVN/text()='test']

But it is not fetching anything

manjosh
  • 438
  • 6
  • 28

1 Answers1

1

Problem: There is no text node child of the address element.

Solution: Test the string value of the address element rather than its (non-existent) text node child...

This XPath,

/sys/platform/contact[address='' and LVN='test']

will select those contact elements whose address string value is an empty string and whose LVN element has a string value of test'.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240