簡體   English   中英

如何在Java中解析具有另一個xml文件作為標記的xml文件?

[英]How to parse xml file which is having another xml file as a tag in java?

我想解析一個xml文件,其標記/節點之一具有另一個xml文件作為數據,因此我如何解析該文件。以下是xml文件:

<?xml version="1.0"?>
<company>
<URL>
<RequestUrl>http://www.google.com
</RequestUrl>
<RequestData>
"<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"     xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><PingMe xmlns="visum.Server.Service" id="o0" c:root="1"><Data i:type="d:string">ping</Data></PingMe></v:Body></v:Envelope>"
</RequestData>
</company>

當我要解析上述xml文件並在Request Data標簽下檢索xml文件時,它沒有返回我另一個xml文件的整個字符串,而只是返回空白字符串,所以我應該如何進行處理?

解析它。 您必須使用CDATA才能使多余的“ XML”不被解釋。

<?xml version="1.0"?>
<company>
<URL>
    <RequestUrl>http://www.google.com</RequestUrl>
    <RequestData>
    <![CDATA[
        <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"                 xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><PingMe xmlns="visum.Server.Service" id="o0" c:root="1"><Data i:type="d:string">ping</Data></PingMe></v:Body></v:Envelope>
    ]]>
    </RequestData>
</URL>
</company>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM