dom4j转换字符串的问题.大家快来看阿[
xml源文件如下:
<?xml version="1.0" ?>
<Envelope>
<dataitem>
<PMTicketSelect>
<sUser></sUser>
<sQCUser></sQCUser>
<sSelectTime></sSelectTime>
<sBackTime></sBackTime>
<sTotalCode></sTotalCode>
<selectsn></selectsn>
<iReturnState></iReturnState>
<iselecttype></iselecttype>
<isChange></isChange>
</PMTicketSelect>
</dataitem>
</Envelope>
java代码如下:
SAXReader reader = new SAXReader();
Document doc = reader.read(new File(fileP));
String cmlStr = doc.asXML();
System.out.println(cmlStr);
输出结果如下:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<dataitem>
<PMTicketSelect>
<sUser/>
<sQCUser/>
<sSelectTime/>
<sBackTime/>
<sTotalCode/>
<selectsn/>
<iReturnState/>
<iselecttype/>
<isChange/>
</PMTicketSelect>
</dataitem>
</Envelope>
问:为什么只输出半个标签?
------解决方案--------------------这也不算是半个标签啊
<sUser></sUser>与<sUser/>在html中是等效的
解析过程中对没有子标签或内容的标签就是按这种方式解析的
------解决方案--------------------因为你的标签里没内容,有的话就输出全了,不信你试试
------解决方案--------------------lz <sUser></sUser>与<sUser/>是等效的