dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the pr
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the pr相关的知识,希望对你有一定的参考价值。
采用dom4j方式解析string类型的xml
xml: String string="<?xmlversion=\"1.0\" encoding=\"UTF-8\"?><ROOT><HEAD><INFO><BUSINESSNO>T065205072015000097</BUSINESSNO><BUSINESSTYPE>T</BUSINESSTYPE></INFO></HEAD></ROOT>";
时,报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.
后来发现原来是xml格式有误。xmlversion应改为xml version.即xml和version之间应该有一个空格。
改为
string="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ROOT><HEAD><INFO><BUSINESSNO>T065205072015000097</BUSINESSNO><BUSINESSTYPE>T</BUSINESSTYPE></INFO></HEAD></ROOT>";就OK了。
以上是关于dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the pr的主要内容,如果未能解决你的问题,请参考以下文章
用dom4j解析xml报错: Error on line 1 of document : Content is not allowed in prolog。