Remove/ignore empty child nodes before/while parsing

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?

    Requires Free Membership to View

    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

    By submitting your registration information to SearchSOA.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSOA.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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.

This was first published in January 2004