I’m using xmlreader to read an XML-file. I want to identify whether an element has child nodes or not.
Currently, I use the IsEmptyElement method to find whether there are child elements. I found out that, even if the tag contains text data and not an element, it returns as true.
if (!file.IsEmptyElement) {
elem.subElems.Add(readXml(file));
}
How van I fix this issue using the xml reader? Any help would be appreciated.
Thank you.
If you just have to check, use XmlDocument instead… I found it to be easier to understand and code.
Reader: