Remove/ignore empty child nodes before/while parsing
I have created an application which creates as well as parses an XML document and displays the data in different forms. I'm facing a problem when I have to parse an XML document with empty nodes. In this case, I cannot be referencing a particular node using firstChild.firstChild syntax because I may end up in referencing an empty child node. Is there a easy way to remove/ignore empty childnodes before/while parsing?
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on recent service-oriented architecture (SOA) and SOA-related topics such as integration, governance, Web services, Cloud and more.
Hannah Smalltree, Editorial Director
I suggest you may need to revisit your algorithmic approach. In situations
where nodes may or may not exist, it is always cumbersome to navigate node
to node. You might want to consider using XPath expressions to gather sets
of nodes into nodelists and process these.
Dig Deeper
-
People who read this also read...
This was first published in January 2004