使用C#从API检索数据 [英] Retrieve Data from API using C#
问题描述
我想找回基于URL地址在C#中的一类内这一数据的 http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT 。
不幸的是,你不能用的XDocument XML = XDocument.Load();检索数据,因为该URL地址不是一个XML文件。
我需要以检索XML的基础上,URL地址中的数据的 http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT ?
谢谢!
的XDocument XML = XDocument.Parse(新WebClient的()。DownloadString(http://sporing.bring.no /sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT));
这可能会解决你的问题。
I would like to retrieve this data inside of a class in c# based on a URL address "http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT".
Unfortunately, you cannot use "XDocument xml = XDocument.Load("");" to retrieve the data because the url address is not a xml file.
What sourcecode in C# do I need in order to retrieve the data of the xml based on the URL address "http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT"?
Thanks!
XDocument xml = XDocument.Parse(new WebClient().DownloadString("http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT"));
This will probably solve your problem.
这篇关于使用C#从API检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!