我的JAVA代码
SAXReader reader = new SAXReader();//通过SAXReader从文件读取XML文档
File file = new File("D:/test.xml");
Document document = reader.read(file);
Element root = document.getRootElement();
报了下面的错
ERROR:Error on line 5 of document file:///D:/test.xml : The processing instruction target matching "[xX][mM][lL]" is not allowed. Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed.
在给你们看看我的test.xml
<?xml version="1.0" encoding="utf-8"?>
<SearchMdInfoByConditionResult xmlns="http://tempuri.org/">
<success xmlns="http://tempuri.org/">1</success>
<retdata xmlns="http://tempuri.org/">
<?xml version="1.0" encoding="utf-8"?>
<root>
<data type="MD_GROUPCUST">
<CustomerCode>B3000002701</CustomerCode>
<GroupTopType>0</GroupTopType>
<GroupShortName>宁夏有限公司</GroupShortName>
<GroupTopName>魏彦辉</GroupTopName>
<GroupTopCodeType>1</GroupTopCodeType>
<GroupTopCode>1330271962015</GroupTopCode>
<BelongCmp></BelongCmp>
<BelongCmpName></BelongCmpName>
<GroupManager>do2ngli@qq.com</GroupManager>
<Remark></Remark>
<ModyPerson>李栋</ModyPerson>
</data>
<data type="MD_GROUPCUST">
<CustomerCode>B3000002676</CustomerCode>
<GroupTopType>0</GroupTopType>
<GroupShortName>内蒙古有限公司</GroupShortName>
<GroupTopName>霍庆华</GroupTopName>
<GroupTopCodeType>1</GroupTopCodeType>
<GroupTopCode>152921180015</GroupTopCode>
<BelongCmp></BelongCmp>
<BelongCmpName></BelongCmpName>
<GroupManager>don2gli@qq.com</GroupManager>
<Remark></Remark>
<ModyPerson>李栋</ModyPerson>
</data>
</root>
</retdata>
</SearchMdInfoByConditionResult>
是不是应为我的xml文件里有2个<?xml version="1.0" encoding="utf-8"?>的原因啊,有没有什么办法让我这个格式的XML也能转换成Document?
侃侃无极
慕雪6442864
相关分类