'I want to get the count of an empty xml file having only closing tag. Using count function. I want to get count as zero

I have an xml payload as

<?xml version="1.0" encoding="UTF-8"?>
<Data/>

While using count(/Data)=0 to check whether the data is zero or not it is not giving me proper results.



Solution 1:[1]

There is one Data element so count(/Data) is 1.

If you want to test whether the Data element has any children, test count(/Data/*) = 0.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Kay