如何在响应标记内解析包含XML文档的SOAP响应
问题描述:
我正在向服务器发送SOAP请求并获取以下响应。我使用DDXMLParser解析响应。但是,解析器将其解释为无效的XML。我很确定<return>
标记中的数据必须包含在[!CDATA]
块中。当使用NSXML Parser
解析时,我得到NSXMLParser Error Domain 64
。 我不确定如何现在进行。如何在响应标记内解析包含XML文档的SOAP响应
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<return>
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>
</return>
</soapenv:Body>
</soapenv:Envelope>
答
任何文档只能有一个XML声明,并且它必须位于文档的开头。
解析器会将此视为嵌套文档或不正确放置XML声明,这两者都会导致错误。
**<?xml version="1.0" encoding="utf-8"?>**
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<return>
**<?xml version="1.0"?>**
<catalog>