The code you posted does not tell you that the "doc" variable contains null. It is possible that its toString() method returns null, or the 4-character string "null", as well. And considering that the getNodeValue() method of an Element node does return null (check the API documentation for org.w3c.dom.Node), it's possible you have misidentified the problem.
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