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

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

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.