【发布时间】:2016-02-04 22:31:58
【问题描述】:
Soap 响应为:
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://example.com/SystemIntegration">
<FirstName>@FirstName</FirstName>
<LastName>@LastName</LastName>
</LoginResponse>
</soap:Body>
</soap:Envelope>
我试图将其解读为:
XDocument doc = XDocument.Parse(strReturnStatus);
List<XElement> result = doc.Elements("LoginResponse").ToList();
for (int intc = 0; intc <= result.Count - 1; intc++)
{
strResponseCode = result[intc].Element("FirstName").Value.ToString();
strResponseText = result[intc].Element("LastName").Value.ToString();
}
但它返回 null 结果。
如何阅读以上回复asp.net c#??
【问题讨论】:
-
这是命名空间规范的问题。参考以下答案:stackoverflow.com/q/12201822/952310