Often beginners with DOM assume that the getFirstChild method will return the first child which is an Element, not noticing that there is a Text node which is all whitespace before that Element in their document. This Text node is the first child.
Have a look at your document to see if that is the case.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: null pointer exception to get first child node while xml parsing