簡體   English   中英

來自Api的Xml文檔為空

[英]Empty Xml Document response from Api

我需要來自imdb非官方api“ omdbapi”的信息。我發送的鏈接正確無誤,但是當我得到響應時,文檔為null。我使用的是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);

它不是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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM