How to parse XML (DataSet) in Windows Phone 7

前端 未结 2 504

I have a XML Like Below, But i am not able to parse it. Please help me to parse the below XML.



        
相关标签:
2条回答
  • 2021-01-29 00:06

    What is blocking you?

    You can try this:

            var resultNewDataSet = XElement.Parse(xmlContent);
    
            var result = resultNewDataSet.Descendants("Table")
                .Select(t => new
                    {
                        aaa = t.Descendants("aaa").First().Value,
                        bbb = t.Descendants("bbb").First().Value
                    });
    
            foreach (var res in result)
            {
                System.Diagnostics.Debug.WriteLine("aaa: " + res.aaa + " / bbb: " + res.bbb);
            }
    
    0 讨论(0)
  • 2021-01-29 00:07

    The element GetResult is also in the http://tempuri.org namespace, so that is why you select clause is not finding anything.

    Anyhow, I would simplify the query to the following:

    public static String myNamespace = "http://tempuri.org/";
    XDocument reader = XDocument.Parse(response);
    XElement resultElement = reader.Descendants(XName.Get("GetResult", myNamespace)).Single();
    
    0 讨论(0)
提交回复
热议问题