Java XML processing entity problem?

前端 未结 3 912
名媛妹妹
名媛妹妹 2021-01-12 00:32

I get the following error when I try to run my java program(it\'s supposed to read an xml file and print out some of the content).

From what I understand there is an

3条回答
  •  深忆病人
    2021-01-12 01:05

    The entity is not an XML-Entity. Its defined in HTML: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

    If you created the XML you can add Entitys to you DTD.

    Something like this one could help: http://gv.ca/dtd/character-entities.dtd

    edit: To fix this issue you can add an DTD to your XML File (if not already defined).

    Your XML:

    
    
    
    

    Your DTD:

    
    
    

    If you provide the DTD to your Application, the error goes away. I wouldn't write alle Entites myself, I would use one from W3C http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent

    How to include the DTD for your XML is another Question. As far as I remember you can set the path to the DTD, or an Catalog-File.

    edit 2: Take a look at the EntityResolver: http://download.oracle.com/javase/1.4.2/docs/api/org/xml/sax/EntityResolver.html

提交回复
热议问题