如何使用Asp.NET从URL读取xml

时间:2015-02-23 02:02:59

标签: c# asp.net xml httpwebrequest

如何在此链接中获取XML代码

https://www.betorder.com/GetLiveScore?qq=62642&sportTypeId=1&fid=0&lang=TR&countryId=all&checkBoxSelected=all

我正在尝试,但它没有

public void sonucAl() 
{
    string adres = "https://www.betorder.com/GetLiveScore?qq=62642&sportTypeId=1&fid=0&lang=TR&countryId=all&checkBoxSelected=all";
    WebRequest gelenIstek = HttpWebRequest.Create(adres);
    WebResponse gelenCevap;
    using (gelenCevap = gelenIstek.GetResponse())
    {
        using (StreamReader donenDeger = new StreamReader(gelenCevap.GetResponseStream()))
        {
            string gelenBilgi = donenDeger.ReadToEnd();
            string gonder = gelenBilgi;
            div.InnerHtml = gonder;
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我认为您所寻找的内容可以在以下文章中找到:

How to load XML from URL on XmlDocument()

从个人经验和基于上面帖子的示例,下面是如何加载xml:

string m_strFilePath = "https://www.betorder.com/GetLiveScore?qq=62642&sportTypeId=1&fid=0&lang=TR&countryId=all&checkBoxSelected=all";
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load(m_strFilePath); //Load NOT LoadXml