采用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了。