找到无效的XML字符(Unicode:0xc) [英] An invalid XML character (Unicode: 0xc) was found

查看:4246
本文介绍了找到无效的XML字符(Unicode:0xc)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Java DOM解析器解析XML文件导致:

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 element content of the document.
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xc) was found in the element content of the document.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)


推荐答案

即使在CDATA块中封装数据时,XML文档中也会有一些字符被消除。

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.

看到这个线程中的dolmens答案: XML中的无效字符

See dolmens answer in this thread: Invalid Characters in XML

他链接到这篇文章: http://www.w3.org/TR/xml/#charsets

基本上,除0x9(TAB),0xA(CR?),0xD(LF?)

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

这篇关于找到无效的XML字符(Unicode:0xc)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆