Getting document as null [#document: null] After parsing XML in java using DocumentBuilder

前端 未结 2 1434
一整个雨季
一整个雨季 2020-12-11 16:37

After parsing the documengt I am getting null, even though the document contains data. Here is my code, I have set all validations to false.

DocumentBuilderF         


        
相关标签:
2条回答
  • 2020-12-11 16:59

    you should add the static modifier to your Document object, I had the same problem and after the parsing action all non-static objects were simply referring to null. Making it static somehow forces java to keep the reference to the created object during the parse action in your variable.

    0 讨论(0)
  • 2020-12-11 17:00

    [#document: null] is just the toString of your doc instance, it doesn't output your whole XML document.

    The instance itself is not null, you can probably continue your processing without a problem.

    0 讨论(0)
提交回复
热议问题