Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C从API检索数据#_C#_Xml_Api - Fatal编程技术网

C# 使用C从API检索数据#

C# 使用C从API检索数据#,c#,xml,api,C#,Xml,Api,我希望根据URL地址“”在c#中的类中检索此数据 不幸的是,您不能使用“XDocument xml=XDocument.Load(“”;”来检索数据,因为url地址不是xml文件 为了基于URL地址“”检索xml的数据,我需要什么C#源代码 谢谢 XDocument xml = XDocument.Parse(new WebClient().DownloadString("http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOI

我希望根据URL地址“”在c#中的类中检索此数据

不幸的是,您不能使用“XDocument xml=XDocument.Load(“”;”来检索数据,因为url地址不是xml文件

为了基于URL地址“”检索xml的数据,我需要什么C#源代码

谢谢

XDocument xml = XDocument.Parse(new WebClient().DownloadString("http://sporing.bring.no/sporing.xml?q=TESTPACKAGE-AT-PICKUPPOINT"));

这可能会解决你的问题

您必须使用webclient下载它。
因为url地址不是xml文件,所以需要下载数据。
?这是一个XML文件。这很好。只需使用
WebClient.DownloadFile
将其下载到字符串中,然后使用
XDocument.Parse()
从字符串中加载它。