我有这种SoapException
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Fault occurred while processing.</faultstring>
<detail>
<ns1:WaybillRegistrationFault xmlns:ns1="http://pod.waybillmanagement.ws.industrysystem.com.ar/">
<errors xmlns:ns2="http://pod.waybillmanagement.ws.industrysystem.com.ar/">
<code>80000</code>
<description>El número de CTG 59455243 ya existe</description>
</errors>
<errors xmlns:ns2="http://pod.waybillmanagement.ws.industrysystem.com.ar/">
<code>1000</code>
<description>Unexpected Error</description>
</errors>
</ns1:WaybillRegistrationFault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>如何读取每个错误?我试过使用Detail.InnerText,但是所有的文本显示都没有格式化。标签上有使用foreach的方法吗?
发布于 2014-08-04 13:59:02
您可以使用LinqToXml轻松地解析该xml。
var errors = XDocument.Parse(yourxmlstring)
.Descendants("errors")
.Select(e => new
{
code = (int)e.Element("code"),
desc = (string)e.Element("description")
})
.ToList();https://stackoverflow.com/questions/25120339
复制相似问题