How to check node contains empty string or space or null in xpath?

I want to check the use of xpath node in xml contains empty string / spaces. What is the xpath expression that I should use?

eg:

 <p:insert_acc_data_file xmlns:p="http://ws.wso2.org/dataservice">
<p:Id>123</p:Id>
<p:Name></p:pName>
</p:insert_acc_data_file>

How to check node name is empty or contains space values?

+4
source share
1 answer

By checking that the node is empty, I think you mean that it does not have a child (text or node).

Checking for the presence of node only space values ​​can be performed using the function normalize-space().

I suggest you use this condition:, not(./*) and normalize-space(.)=""i.e.

  • has no child nodes
  • , node
+6

Source: https://habr.com/ru/post/1541728/


All Articles