2012-08-14 159 views
0

这是从webservice返回的XML回应。如何获取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> 

在这XML,我得到了11个项目在一个数组中。我如何反序列化它并逐个获取项目?

回答