【问题标题】:Empty Xml Document response from Api来自 Api 的空 Xml 文档响应
【发布时间】:2023-03-12 22:52:01
【问题描述】:

我需要来自 imdb 非官方 api“omdbapi”的信息。我正在发送正确的链接,但是当我得到响应时,文档为空。我正在使用 htmlagiltypack。我做错了什么?

这里是直接链接:http://www.omdbapi.com/?i=tt2231253&plot=short&r=xml

        string url = "http://www.omdbapi.com/?i=" + ImdbID + "&plot=short&r=xml"; 
        HtmlWeb source = new HtmlWeb();
        HtmlDocument document = source.Load(url);

【问题讨论】:

    标签: c# asp.net xml html-agility-pack


    【解决方案1】:

    它不是 Html,而是您期望的 XML 文档。试试这个:

     string url = "http://www.omdbapi.com/?i=tt2231253&plot=short&r=xml";
     WebClient wc = new WebClient();
     XDocument doc = XDocument.Parse(wc.DownloadString(url));
     Console.WriteLine(doc);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 2014-05-10
      • 2011-04-30
      相关资源
      最近更新 更多