how to download data from file xml
如何从文件xml下载数据
data file in the application
应用程序中的数据文件
XDocument dane = XDocument.Load("gpw.xml");
List<pozycjeGpw> listaGpw = new List<pozycjeGpw>();
private void listBox1_Loaded(object sender, RoutedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
listaGpw = (from item in dane.Descendants("pozycja")
select new pozycjeGpw()
{
nazwa_notowania = (item.Element("nazwa_notowania").Value),
biezacy = (item.Element("biezacy").Value),
zmiana = (item.Element("zmiana").Value),
zmiana2 = (item.Element("zmiana2").Value),
otwarcie = (item.Element("otwarci").Value),
max = (item.Element("max").Value),
min = (item.Element("min").Value),
}).ToList();
listaGpw.Insert(0, new pozycjeGpw() { nazwa_notowania = "", biezacy = "", zmiana = "", zmiana2 = "", otwarcie = "", max = "", min = "" });
}
2 个解决方案
#1
0
How about:
WebClient webClient = new WebClient();
String result = webClient.DownloadString(yourUrlOfTheXmlFile);
textBox.Text = result;
Doing this in a form with a TextBox called textBox should display the downloaded xml file on the screen.
使用名为textBox的TextBox在表单中执行此操作应在屏幕上显示下载的xml文件。
If you want to load this XML from a file on your system, you can also use this:
如果要从系统上的文件加载此XML,还可以使用以下命令:
String result = File.ReadAllText(pathOfYourXmlFile);
textBox.Text = result;
#2
0
I'm not entirely sure what you want to do but from your comments it appears that you have an xml file and you want to display it in a WPF application. To do this you can use XMLDataProvider
and HierarchicalDataTemplates
/ DataTemplates
. Here is a short tutorial on how to do it: http://dotnet-experience.blogspot.com/2011/11/wpf-working-with-xml-and.html
我不完全确定你想要做什么,但从你的评论看来你有一个xml文件,你想在WPF应用程序中显示它。为此,您可以使用XMLDataProvider和HierarchicalDataTemplates / DataTemplates。这是一个关于如何做到这一点的简短教程:http://dotnet-experience.blogspot.com/2011/11/wpf-working-with-xml-and.html
#1
0
How about:
WebClient webClient = new WebClient();
String result = webClient.DownloadString(yourUrlOfTheXmlFile);
textBox.Text = result;
Doing this in a form with a TextBox called textBox should display the downloaded xml file on the screen.
使用名为textBox的TextBox在表单中执行此操作应在屏幕上显示下载的xml文件。
If you want to load this XML from a file on your system, you can also use this:
如果要从系统上的文件加载此XML,还可以使用以下命令:
String result = File.ReadAllText(pathOfYourXmlFile);
textBox.Text = result;
#2
0
I'm not entirely sure what you want to do but from your comments it appears that you have an xml file and you want to display it in a WPF application. To do this you can use XMLDataProvider
and HierarchicalDataTemplates
/ DataTemplates
. Here is a short tutorial on how to do it: http://dotnet-experience.blogspot.com/2011/11/wpf-working-with-xml-and.html
我不完全确定你想要做什么,但从你的评论看来你有一个xml文件,你想在WPF应用程序中显示它。为此,您可以使用XMLDataProvider和HierarchicalDataTemplates / DataTemplates。这是一个关于如何做到这一点的简短教程:http://dotnet-experience.blogspot.com/2011/11/wpf-working-with-xml-and.html