How to make xml file in C # for use with .iqy, which imports as datatable

I want to create an excel file where data is collected and updated automatically from my site and displayed as data tables.

I tried to import the website from the website from the created table, but not formatted as a data table.

I also created an xml file and used the .iqy file to get the data, and yet it is not imported as a data table

This is my .iqy file that will import data, but not as xml

WEB 1 http://localhost:55369/files/SerializationOverview.xml 

This is my test XML file

  <?xml version="1.0"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore> 

Thanks in advance for any help greatly appreciated.

+4
source share
1 answer

Read the third / last line of your .iqy file:

 var url = File.ReadLines(@"query.iqy").Take(3).Last(); 

Then download xml using:

 using (var wc = new System.Net.WebClient()) { contents = wc.DownloadString(url); } 

And then we XDocument.Parse(contents) xml using XDocument.Parse(contents) , go through xml and write the data to the database.

0
source

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


All Articles