解析xml数据
问题描述:
我有以下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>
答