我有一个像下面的XML,但我无法解析它。请帮我解析下面的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 xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<aaa>hi1</aaa>
<bbb>hi2</bbb>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<aaa>hi3</aaa>
<bbb>hi4</bbb>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetResponse></GetResult>
</soap:Body>
</soap:Envelope>
这里我想要表格(即a,b)标签的结果。我尝试使用Linq,但我无法解析它。我尝试了这样的代码:
String response = e.response;
public static String myNamespace = "http://tempuri.org/";
XDocument reader = XDocument.Parse(response);
XElement resultElement = reader.Descendants(XName.Get("GetResult", myNamespace)).Single();
XElement resultNewDataSet= resultElement.Descendants(XName.Get("NewDataSet", "")).Single();
所以现在在resultNewDataSet中我得到了XML Like Below:
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<aaa>hi1</aaa>
<bbb>hi2</bbb>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<aaa>hi3</aaa>
<bbb>hi4</bbb>
</Table>
</NewDataSet>
那么现在我怎样才能找到aaa tag和bbb tag的值?
提前致谢。