`
border
  • 浏览: 201339 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

dom4j解析特殊字符出错

    博客分类:
  • Java
阅读更多
用DocumentHelper.parseText(text)解析的时候,text里面有些特殊字符,比如\0x07, \0x13,这些,就报异常。有什么办法处理嘛?
分享到:
评论
4 楼 damoqingquan 2008-10-17  
但是需要解析的文本是固定生成的,若对某个字符进行转义,可能会将合法的部分也转义,这样就达不到解决效果了啊。
到底如何是好呢?
3 楼 阳光晒晒 2008-10-16  
解析之前转意
2 楼 damoqingquan 2008-10-16  
我也遇到通用的问题,不知道怎么解决才好!
1 楼 border 2007-10-21  
还以为CDATA可以躲过一截,结果还是报错。。。

org.dom4j.DocumentException: Error on line 24 of document  : An invalid XML character (Unicode: 0x13) was found in the CDATA section. Nested exception: An invalid XML character (Unicode: 0x13) was found in the CDATA section.
	at org.dom4j.io.SAXReader.read(SAXReader.java:482)
	at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
	at book.xml.dom4j.StringToDoc.main(StringToDoc.java:32)
Nested exception: 
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x13) was found in the CDATA section.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanCDATASection(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
	at book.xml.dom4j.StringToDoc.main(StringToDoc.java:32)
Nested exception: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x13) was found in the CDATA section.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanCDATASection(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
	at book.xml.dom4j.StringToDoc.main(StringToDoc.java:32)
Exception in thread "main" java.lang.NullPointerException
	at book.xml.dom4j.StringToDoc.main(StringToDoc.java:36)

相关推荐

    高效的 RapidJSON 解析/生成器支持库,提供 SAX 及 DOM 操作

    高效的 C++ JSON 解析/生成器,提供 SAX 及 DOM 风格 API 简介 RapidJSON 是一个 C++ 的 JSON 解析器及生成器。它的灵感来自 RapidXml。 RapidJSON 小而全。它同时支持 SAX 和 DOM 风格的 API。SAX 解析器只有约 ...

    详解Js模板引擎(TrimPath)

     得到页面中Id为elementId的DOM组件的InnerHTML,将其解析成一个模板,这个返回一个templateObject对象,解析出错时将抛出一个异常。  optionalDocument一个可选参数,在使用iframe,frameset或者默认多文档时会...

    Discuz! X2 R20120628 繁体UTF-8.zip

    FIX DIY模块调取含有$和\字符时模板解析出错的问题 FIX 关于专题评论后的伪静态链接错误问题。 FIX 修正由存档表引起的分页错乱的BUG FIX 后台管理团队开启允许导航设置的问题 FIX 过滤...

    Discuz! X2 R20120628 简体GBK.zip

    FIX DIY模块调取含有$和\字符时模板解析出错的问题 FIX 关于专题评论后的伪静态链接错误问题。 FIX 修正由存档表引起的分页错乱的BUG FIX 后台管理团队开启允许导航设置的问题 ...

    Discuz! X2 R20120628 繁体BIG5.zip

    FIX DIY模块调取含有$和\字符时模板解析出错的问题 FIX 关于专题评论后的伪静态链接错误问题。 FIX 修正由存档表引起的分页错乱的BUG FIX 后台管理团队开启允许导航设置的问题 FIX 过滤exif信息 ...

    Discuz! X2 R20120628 简体UTF-8.zip

    FIX DIY模块调取含有$和\字符时模板解析出错的问题 FIX 关于专题评论后的伪静态链接错误问题。 FIX 修正由存档表引起的分页错乱的BUG FIX 后台管理团队开启允许导航设置的问题 FIX 过滤...

    超级有影响力霸气的Java面试题大全文档

    4. 多态性:  多态性是指允许不同类的对象对同一消息作出响应。多态性包括参数化多态性和包含多态性。多态性语言具有灵活、抽象、行为共享、代码共享的优势,很好的解决了应用程序函数同名问题。 5、String是最...

    DWR.xml配置文件说明书(含源码)

    DWR 自动将DOM、DOM4J、JDOM和XOM转换成DOM树,前面这几种类型都仅仅返回Document,Element,Node.DWR会自动将这些转换成浏览器DOM对象.通常在启动JDOM Converter时会有一个提示信息,除非你想采用JDOMconverter否则可以...

    白帽子讲浏览器安全.钱文祥(带详细书签).pdf

    2.1.5 自纠错与Unicode字符分解映射 20 2.1.6 登录信息钓鱼攻击 23 2.2 HTTP协议 24 2.2.1 HTTP HEADER 25 2.2.2 发起HTTP请求 26 2.2.3 Cookie 28 2.2.4 收到响应 29 2.2.5 HTTP协议自身的安全问题 31 ...

    XML轻松学习手册--XML肯定是未来的发展趋势,不论是网页设计师还是网络程序员,都应该及时学习和了解

    4.DOM则为脚本和对象的交流提供一个公共平台,并将结果显示在浏览器窗口。 如果任何一个部分发生错误,都不会得到正确结果。 好了,看到这里,我们已经对XML是如何工作的有一个整体的大致的概念。通过这一章的...

    #RAPIDJSON_LIB1.1#20200314版(rapidjson.fne)-易语言

    高效的 C++ JSON 解析/生成器,提供 SAX 及 DOM 风格 API 简介 RapidJSON 是一个 C++ 的 JSON 解析器及生成器。它的灵感来自RapidXml 。 RapidJSON 小而全。它同时支持 SAX 和 DOM 风格的 API。SAX 解析器只有约 ...

    精易模块[源码] V5.15

    1、修正“编码_ansi到usc2”当末尾出现10或13字符时出错的BUG,感谢易友【@rmcs】反馈。 2、改名“文件_搜索1”改为“文件_搜索_深度”并修正备注及深度问题,感谢易友【@小爬虫】反馈。 3、改善“时间_取现行时间戳...

    精易官方免费模块v3.60版

    5.完善 DLL“_宽字符到双字节”和“_宽字符到双字节1”的备注 方便区分 1.修复“编码_Unicode到Utf8”,感谢 90后辉煌 的提醒 2.修复“系统_取宽带用户名密码”因 编码_Unicode到Utf8 有问题导致的问题 感谢 wjjucwj...

Global site tag (gtag.js) - Google Analytics