Check if XML node is empty
- by Vinit
I have a simple XML structure like
<main>
<node1><!-- comments --><!-- comments --></node1>
</main>
and this can have any number of sub-nodes or values like:
<main>
<node1><!-- comments --><!-- comments --><p>texttext text</p>
more text <br/></node1>
</main>
I want to check if the node is empty or not:
I'm doing something like:
<xsl:if test="string-length(main/node1//text())>0">
But it does not work as if there are multiple tags, then string-length function will break coz of multiple arguments. Any help to solve this issue is really appreciated.