Check if a node's text is empty

Other topics

Remarks:

Boolean function has other uses

  1. Check if a node is present
  2. Check if the argument is not a number (NaN) or is 0

String function is used to return the string value of a node.

Check if Deborah has a master and its text value is not empty

XML

<Deborah>
    <address>Dark world</address>
    <master>Babadi</master>
    <ID>#0</ID>
    <colour>red</colour>
    <side>evil</side>
</Deborah>

XPATH

boolean(/Deborah/master/text())

OR

string(/Deborah/master) != ''

OUTPUT

true

Check if Dobby has a master and its text value is not empty

XML

<Dobby>
    <address>Hogwartz</address>
    <master></master>
    <colour>wheatish</colour>
    <side>all good</side>
</Dobby>

XPATH

boolean(/Dobby/master/text())

OR

string(/Dobby/master) != ''

OUTPUT

false

Syntax:

  • boolean(path_to_node/text())
  • string(path_to_node) != ''

Contributors

Topic Id: 7445

Example Ids: 24623,24624

This site is not affiliated with any of the contributors.