【发布时间】:2018-04-10 15:19:33
【问题描述】:
我有一个示例响应:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<trk:TrackResponse xmlns:trk="somens1">
<common:Response xmlns:common="somens2">
<common:ResponseStatus>
<common:Code>1</common:Code>
<common:Description>Success</common:Description>
</common:ResponseStatus>
<common:TransactionReference>
<common:CustomerContext>Sample Response</common:CustomerContext>
</common:TransactionReference>
</common:Response>
</trk:TrackResponse>
</soapenv:Body>
</soapenv:Envelope>
我想删除Envelope、Header 和Body 标记,只使用从TrackResponse 开始的xml。
我正在尝试使用jdom 遍历响应。
Element body = jdom.getRootElement().getChild("Body", Namespace.getNamespace("http://schemas.xmlsoap.org/soap/envelope/"));
我实际上需要从 TrackResponse 开始的 jdom Element 检索到的 jdom Document 对象。
解决方案还是更好的替代方案?
【问题讨论】: