我有一个XML Like Below,但我无法解析它。请帮我解析下面的XML。如何解析Windows Phone 7中的soap XML
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>
<GetResponse xmlns="http://tempuri.org/"><GetResult>
<diffgr:diffgram>
<NewDataSet>
<Table>
<a>hi1</a>
<b>hi2</b>
</Table>
<Table>
<a>hi3</a>
<b>hi4</b>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetResponse></GetResult>
</soap:Body>
</soap:Envelope>
这里我想要表(即a,b)标记的结果。我尝试使用Linq,但我无法解析它。我试了一下这样的代码:
//XML will be there in response string
String response = e.response;
public static String myNamespace = "http://tempuri.org/";
XDocument reader = XDocument.Parse(response);
var results = from result in reader.Descendants(XName.Get("GetResponse", myNamespace))
select result.Element("GetResult").
但是这段代码返回null。
谢谢提前。
那么,为什么你不只是生成与模式的客户端,让净为您做解析? – Bashwork 2011-12-23 15:30:05
谢谢Bashwork。但我想在Windows Phone 7中解析这个XML。我可以在WP7中解析这个XML。 – 2011-12-24 08:24:41
@MahiKumar - 您可以在WP7项目中设置服务参考。或者你的意思是说应该是动态的,因为模式每次都会有所不同? – 2011-12-24 08:38:58