How to load XML into DataTable?

I want to upload an XML file on the Internet to a DataTable in C #. XML is downloaded from http://rates.fxcm.com/RatesXML and looks like this:

 <?xml version="1.0" encoding="UTF-8"?> <Rates> <Rate Symbol="EURUSD"> <Bid>1.29174</Bid> <Ask>1.29198</Ask> <High>1.29407</High> <Low>1.28723</Low> <Direction>-1</Direction> <Last>14:56:48</Last> </Rate> <Rate Symbol="USDJPY"> <Bid>82.862</Bid> <Ask>82.885</Ask> <High>83.293</High> <Low>82.847</Low> <Direction>1</Direction> <Last>14:56:47</Last> </Rate> <!-- More like the above --> </Rates> 

Can I use the ReadXml method of the DataTable class to read XML or do I need some kind of http request to wrap it in a string?

EDIT: I just wrote the following

 public DataTable GetCurrentFxPrices(string URL) { DataSet ds = new DataSet("fxPrices"); ds.ReadXml(URL); } 

and he is trying to read the data, but I'm behind the corporate firewall. I really don't know how to get around this. I get this error:

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

In firefox, I have an HTTP proxy with a port number. Can I install this somewhere in my application?

0
source share
2 answers

Yes, you can use ReadXml if the XML is in single table format.

It may not appear in the format you expect, so you may need to learn a little about the structure of the data set, but it works fine.

As a rule, when loading data from an XML file into a Datatable, I first read it in a DataSet and made sure that it does not create more than one table. Any nesting inside XML usually results in multiple tables in a DataSet.

This particular file, however, looks like it will only import into one table.

+3
source

This is a different question than the original, so to answer the amended question ...

Typically, .NET uses your system settings. I believe that your default proxy settings are configured in Internet Explorer. In other words, if you install it in IE, then Windows will generally use these settings.

I will try to install a proxy server in Internet Explorer and see if your application can access it from your application.

I found another possibility here: http://www.musicalnerdery.com/net-programming/reading-an-xml-document-from-behind-a-proxy.html

+1
source

Source: https://habr.com/ru/post/1335092/