Java XML Parsing: Avoid entity reference resolution

前端 未结 1 1463
花落未央
花落未央 2020-12-05 22:23

I am currently parsing XHTML documents with a DOM parser, like:

final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(fa         


        
相关标签:
1条回答
  • 2020-12-05 22:41

    The approach I took was to replace any entities with a unique marker that is treated as plain text by Xerces. Once converted into a Document object, the markers are replaced with Entity Reference objects.

    See the convertStringToDocument() function in http://sourceforge.net/p/commonclasses/code/14/tree/trunk/src/com/redhat/ecs/commonutils/XMLUtilities.java

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