如何使用Windows Phone(c#)从该XML获取信息? PARSE怎么样? [英] How to get information from that XML by using Windows Phone(c#) ? How to PARSE it ?

查看:63
本文介绍了如何使用Windows Phone(c#)从该XML获取信息? PARSE怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.namaz.web.tr/namazVakitleriApi.php?ilListesi=1 [ ^ ]

推荐答案

试试这个:

try this:
WebClient client = new WebClient();
        client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
        Uri url = new Uri("http://www.namaz.web.tr/namazVakitleriApi.php?ilListesi=1", UriKind.Absolute);
        client.OpenReadAsync(url);










public void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    try
    {
        var xml = XDocument.Load(e.Result);
        
        var results = from row in xml.Element("sehirListesi").Elements().Where( element.Contains("A") { return (element.Name.LocalName == "Result"); } )
                      select row;

        // now I loop all rows and print the title; of course you can
        // do other stuff here or combine some data processing with the LINQ above
        // - this is up to you
        foreach (var result in results)
        {
                Debug.WriteLine(result.Value.Value);
        }
    }
    catch (Exception c)
    {
        MessageBox.Show(c.Message);
    }
}


这篇关于如何使用Windows Phone(c#)从该XML获取信息? PARSE怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆