Java documentbuilder.parse #document null
Your real problem is your interpretation of the output - you got a Document object ok - the null comes from the toString interpretation of a Document object. You should become familiar with the org. Node JavaDocs. There is a very useful table there showing what the "value" of every Node type is.
For a Document Node, that is always null. I figured out what my particular problem was. The code I had posted was combined for simplicity's sake. Skip navigation links. Object javax. Using this class, an application programmer can obtain a Document from XML. Obtain an instance of a DOMImplementation object. Specify the ErrorHandler to be used by the parser. Reset this DocumentBuilder to its original configuration. An IllegalArgumentException is thrown if the File is null null. I am fixing a bug on an existing code concerning DocumentBuilder.
Pink Angel Pink Angel 2 2 gold badges 5 5 silver badges 15 15 bronze badges. The parse method should either return a document or throw an exception but never return null WeishiZeng, it's covered by the exhaustive documentation.
Even if that did not exhaust all the error cases, it's conventional in the JDK for the returns documentation to mention null if it's a possible return value. Show 1 more comment. Active Oldest Votes. Andreas Dolk Andreas Dolk k 16 16 gold badges silver badges bronze badges. Will this method ever return null or throw exception in those cases? Thanks for letting me know that: xmlDoc. Add a comment. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name.
0コメント