使用XMLDictionary解析

时间:2015-06-17 10:09:38

标签: ios objective-c

我正在使用' XMLDictionary'解析xml。在一个案例中,我得到以下字典(在使用' dictionaryWithXMLData'将NSData响应转换为NSDictionary之后)

{
"__name" = "soap:Envelope";
"_xmlns:soap" = "http://schemas.xmlsoap.org/soap/envelope/";
"_xmlns:xsd" = "http://www.w3.org/2001/XMLSchema";
"_xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
"soap:Body" =     {
    GetPublicationsListResponse =         {
        GetPublicationsListResult = 0;
        "_xmlns" = "http://questbase.org/";
        publicationsList = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<publications>\n  <publication>\n    <pin>4533-1490-8280</pin>\n    <title>Unsecure Assessment</title>\n    <isSecure>0</isSecure>\n  </publication>\n  <publication>\n    <pin>5123-4751-0595</pin>\n    <title>Secure Assessment</title>\n    <isSecure>1</isSecure>\n  </publication>\n</publications>";
        studentID = "4795e7fc-5c98-4ec4-a155-5f719f14ef3e";
    };
};

}

这里,关键的publicationList的对象是xml,我试图将其转换为NSDictionary。 Plz帮助。

原始xml请求的格式为:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SecurityHeader xmlns="http://questbase.org/">
      <Password>string</Password>
    </SecurityHeader>
  </soap:Header>
  <soap:Body>
    <GetPublicationsList xmlns="http://questbase.org/">
      <accountName>string</accountName>
      <userName>string</userName>
      <password>string</password>
      <ipAddress>string</ipAddress>
      <userAgent>string</userAgent>
    </GetPublicationsList>
  </soap:Body>
</soap:Envelope>

,回复如下:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetPublicationsListResponse xmlns="http://questbase.org/">
      <GetPublicationsListResult>int</GetPublicationsListResult>
      <studentID>guid</studentID>
      <publicationsList>string</publicationsList>
    </GetPublicationsListResponse>
  </soap:Body>
</soap:Envelope>

0 个答案:

没有答案