简体   繁体   English

来自Api的Xml文档为空

[英]Empty Xml Document response from Api

I need information from imdb unoffical api "omdbapi".I am sending link in correct but when I get response the document is null.I am using htmlagiltypack.what am I doing wrong? 我需要来自imdb非官方api“ omdbapi”的信息。我发送的链接正确无误,但是当我得到响应时,文档为null。我使用的是htmlagiltypack。我在做什么错了?

here is direct link: http://www.omdbapi.com/?i=tt2231253&plot=short&r=xml 这是直接链接: 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);

Its no Html but a XML document you expect. 它不是HTML,而是您期望的XML文档。 Try this instead: 尝试以下方法:

 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