2013-05-14 67 views
0

我正在向服務器發送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> 

回答

1

任何文檔只能有一個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>