dom4j解析xml報錯:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM