【发布时间】:2012-01-27 11:19:54
【问题描述】:
我想用 XPath 解析 SOAP 消息,但在 XML 响应中是内部引用。 XPath 不能解决这些问题。是否可以在使用 XPath 之前自动解析引用,以便我可以使用 xpath 表达式,如“//get_referencesResponse/Result/source/item” 还是有更好的阅读文档的方法?
<SOAP-ENV:Body>
<get_referencesResponse SOAP-ENC:root="1" id="i1">
<Result href="#i2"/>
</get_referencesResponse>
<Result SOAP-ENC:root="0" id="i2">
<source href="#i3"/>
<malware href="#i4"/>
[...]
</Result>
<source SOAP-ENC:arrayType="xsd:string[2]" SOAP-ENC:root="0" id="i3" xsi:type="SOAP- ENC:Array">
<item href="#i8"/>
<item href="#i9"/>
</source>
<malware SOAP-ENC:arrayType="xsd:string[7]" SOAP-ENC:root="0" id="i4" xsi:type="SOAP-ENC:Array">
<item href="#i10"/>
<item href="#i11"/>
<item href="#i12"/>
[...]
</malware>
[...]
<item SOAP-ENC:root="0" id="i8" xsi:type="xsd:string">address</item>
<item SOAP-ENC:root="0" id="i9" xsi:type="xsd:string">network_prefix</item>
<item SOAP-ENC:root="0" id="i10" xsi:type="xsd:string">md5</item>
[...]
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
【问题讨论】:
标签: java xml soap xpath xml-parsing