An invalid XML character (Unicode: 0xc) was found

后端 未结 9 2017
傲寒
傲寒 2020-12-02 12:38

Parsing an XML file using the Java DOM parser results in:

[Fatal Error] os__flag_8c.xml:103:135: An invalid XML character (Unicode: 0xc) was found in the ele         


        
相关标签:
9条回答
  • 2020-12-02 13:10

    The character 0x0C is be invalid in XML 1.0 but would be a valid character in XML 1.1. So unless the xml file specifies the version as 1.1 in the prolog it is simply invalid and you should complain to the producer of this file.

    0 讨论(0)
  • 2020-12-02 13:11

    There are a few characters that are dissallowed in XML documents, even when you encapsulate data in CDATA-blocks.

    If you generated the document you will need to entity encode it or strip it out. If you have an errorneous document, you should strip away these characters before trying to parse it.

    See dolmens answer in this thread: Invalid Characters in XML

    Where he links to this article: http://www.w3.org/TR/xml/#charsets

    Basically, all characters below 0x20 is disallowed, except 0x9 (TAB), 0xA (CR?), 0xD (LF?)

    0 讨论(0)
  • 2020-12-02 13:14

    All of these answers seem to assume that the user is generating the bad XML, rather than receiving it from gSOAP, which should know better!

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