tags:

views:

3386

answers:

2

Here is a sample soap response from my SuperDuperService:

<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"&gt;
    <soap:Body>
     <MyResponse xmlns="http://mycrazyservice.com/SuperDuperService"&gt;
      <Result>32347</Result> 
     </MyResponse>
    </soap:Body>
</soap:Envelope>

For some reason when I try to grab the Descendant or Element of "Result" I get null. Does it have something to do with the Namespace? Can someone provide a solution to retrieve Result from this?

Thanks.

+2  A: 

You might want to try something like this:

string myNamespace= "http://mycrazyservice.com/SuperDuperService";

var results = from result in yourXml.Descendants(XName.Get("MyResponse", myNamespace))
              select result.Element("Result").value

Don't have VS on this laptop so I can't double check my code, but it should point you in the right direction using LINQ to SQL.

Justin Niessner
A: 

Maybe like this:

IEnumerable<XElement> list = doc.Document.Descendants("Result");
if (list.Count() > 0)
{
    // do stuff
}
Paw Baltzersen