str*_*and 5 c# xml parsing soap
以下是来自SuperDuperService的示例soap响应:
<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>
<MyResponse xmlns="http://mycrazyservice.com/SuperDuperService">
<Result>32347</Result>
</MyResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我试图抓住"结果"的后代或元素时,我得到了空.它与命名空间有关吗?有人可以提供从中检索结果的解决方案吗?
Jus*_*ner 11
您可能想尝试这样的事情:
string myNamespace= "http://mycrazyservice.com/SuperDuperService";
var results = from result in yourXml.Descendants(XName.Get("MyResponse", myNamespace))
select result.Element("Result").value
Run Code Online (Sandbox Code Playgroud)
在这台笔记本电脑上没有VS,所以我不能仔细检查我的代码,但它应该使用LINQ to SQL指向正确的方向.