2010-09-27 130 views
0

我有以下XML數據。在無效請求或輸入的情況下,如何跟蹤錯誤標籤?解析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:Body> 
    <Signin xmlns="http://tempuri.org/"> 
    <card_number> 123/321 </ card_number > 
    <dob>MM|DD|YYYY </dob > 
    </Signin> 
    </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> 
    <SigninResponse xmlns="http://tempuri.org/"> 
     <user> 
     <user_id>long</user_id> 
     <current_balance>string</current_balance> 
     <card_iamge><![CDATA[string]]></card_iamge> 
     </user> 
    </SigninResponse> 
    </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> 
    <TransactionHistory xmlns="http://tempuri.org/"> 
    <user_id>1/2 </ user_id > 


    </TransactionHistory> 
    </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> 
    <TransactionHistoryResponse xmlns="http://tempuri.org/"> 
     <transactions> 
     <transaction> 
    <date><![CDATA[08/30/2010]]></date> 
    <amt>$10.50</amt> 
    <card>ASYU763543</card> 
     </transaction> 
     <transaction> 
    <date><![CDATA[08/30/2010]]></date> 
    <amt>$10.50</amt> 
    <card>ASYU763543</card> 
     </transaction> 
<transaction> 
    <date><![CDATA[08/30/2010]]></date> 
    <amt>$10.50</amt> 
    <card>ASYU763543</card> 
     </transaction> 
     </transactions> 
    </TransactionHistoryResponse> 
    </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> 
    <*Response xmlns="http://tempuri.org/"> 
    < error> string </ error > 
    </<*Response> 
    </soap:Body> 
</soap:Envelope> 

回答