2012-08-14 8 views
0

Il s'agit de la réponse XML de retour depuis webservice.Comment obtenir des réponses SOAP?

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:OrientalServices1"> 
<SOAP-ENV:Body> 
<ns1:Get_CategoryResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"> 
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:responseGetCategoryByID[11]"> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">1</id> 
    <name xsi:type="xsd:string">國內</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">2</id> 
    <name xsi:type="xsd:string">財經</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">3</id> 
    <name xsi:type="xsd:string">社會</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">4</id> 
    <name xsi:type="xsd:string">國際</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">10</id> 
    <name xsi:type="xsd:string">龍門陣</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">11</id> 
    <name xsi:type="xsd:string">言論</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">6</id> 
    <name xsi:type="xsd:string">名家</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">8</id> 
    <name xsi:type="xsd:string">娛樂</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">5</id> 
    <name xsi:type="xsd:string">體育</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">7</id> 
    <name xsi:type="xsd:string">專題</name> 
</item> 
<item xsi:type="tns:responseGetCategoryByID"> 
    <id xsi:type="xsd:int">9</id> 
    <name xsi:type="xsd:string">特輯</name> 
</item> 
</return> 
</ns1:Get_CategoryResponse> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

Dans ce XML, j'ai obtenu 11 points dans un tableau. Comment puis-je le désérialiser et obtenir l'article un par un?

Répondre

0

Vous pouvez utiliser un analyseur XML.

Il y a un support pour quelques méthodes dans Cocoa - mais comme vous avez posé une question aussi générale, je ne peux que vous donner une réponse générale.

Il existe un Introduction to Event Driven XML Programming sur le site de développement Apple

Questions connexes