如何在xml文件上进行选择语句 [英] how to make select statements on xml file
本文介绍了如何在xml文件上进行选择语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个显示XML文件数据的网格视图.我想使用下拉框在gridview上执行过滤.
例如:
我在xml数据中有名称,城市,位置
在下拉菜单中我有位置
当发生下拉更改事件时,我想在gridview上显示特定的位置详细信息.
我的问题是我不知道如何从xml到comapre中选择垂直元素值.
我对xml数据库非常陌生.
Hi All,
i have a grid view with displaying xml file data. i want to perform filter on gridview using dropdown box .
ex:
i have name ,city,location in xml data
in dropdown i had location
when dropdown change event occures i want to display particular location details on gridview.
my prob is i don''t know how to select perticular element value from xml to comapre.
i am very new to xml database.
推荐答案
1.将XML读入数据集
http://social.msdn.microsoft.com /Forums/zh-CN/csharpgeneral/thread/67dacbbf-6358-4de7-b398-293e89cab6b1/ [ http://social.msdn.microsoft.com/Forums/lv/adodotnetdataset/thread/23fb3bf1-a6f5-446a-8ffa-564a78509d06 [ http://stackoverflow.com/questions/6001086/querying-a-datatable-using-linq [^ ]
1. Read the XML into a Dataset
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/67dacbbf-6358-4de7-b398-293e89cab6b1/[^]
2. use query on dataset
http://social.msdn.microsoft.com/Forums/lv/adodotnetdataset/thread/23fb3bf1-a6f5-446a-8ffa-564a78509d06[^]
http://stackoverflow.com/questions/6001086/querying-a-datatable-using-linq[^]
我给您链接,希望它能给您xml的简要说明并解决您的查询
面向初学者和专家的XML [
i give you links i hope it will give you brief idea of xml and solve your query
XML for beginners and experts[^]
best of luck
i am give you simple example i think it will more help you
using System.IO;
using System.Xml;
private void readDatafromXML(string file_Path)
{
DataSet DS_purchase;
int timeout = Server.ScriptTimeout;
Server.ScriptTimeout = int.MaxValue;
FileInfo FInfo = new FileInfo(file_Path);
if (FInfo.Exists)
{
XmlTextReader xmlReader;
xmlReader = new XmlTextReader(FInfo.FullName);
try
{
DS_purchase.ReadXml(xmlReader);
xmlReader.Close();
}
catch (Exception ex)
{
xmlReader.Close();
lbl_err.Text = "Error in Reading XML file " + ex.Message;
}
finally
{
xmlReader.Close();
}
}
else
lbl_err.Text = "Session Has been expired.please Try again. ";
// on this dataset you can create your query
}
这篇关于如何在xml文件上进行选择语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文