使用C#从API检索数据 [英] Retrieve Data from API using C#

查看:177
本文介绍了使用C#从API检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找回基于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆