ASP.NET and XML
-
Hi all, I want a help from you. I have an XML file in which i have my database. I want to retrive one record from it based on condition. Like we query the database like "select * from TableName where Name='soandso'". But here my database itself is an XML file. Is it possible in anyway. I have tried navigation but i am stuck. Cant seem to go forward in this. Please help me as soon as possible. Regards, Lavanya:)
-
Hi all, I want a help from you. I have an XML file in which i have my database. I want to retrive one record from it based on condition. Like we query the database like "select * from TableName where Name='soandso'". But here my database itself is an XML file. Is it possible in anyway. I have tried navigation but i am stuck. Cant seem to go forward in this. Please help me as soon as possible. Regards, Lavanya:)
hai, Use this code.
DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("filename with path")); //for string data DataRow[] drs = ds.Tables[0].Select("column name = '" + "needed filter value" + "'"); //for numeric data DataRow[] drs = ds.Tables[0].Select("column name = " + "filter value");
read the xml to the dataset and use needed filter in the select method of datatable object.now the drs is collection of rows satisfying your condition. iterate that and use it. i think this solves your problem. Cheers asithangae -
Hi all, I want a help from you. I have an XML file in which i have my database. I want to retrive one record from it based on condition. Like we query the database like "select * from TableName where Name='soandso'". But here my database itself is an XML file. Is it possible in anyway. I have tried navigation but i am stuck. Cant seem to go forward in this. Please help me as soon as possible. Regards, Lavanya:)
Hi Lavanya, you can use xQuery in asp.net. This article may help you. http://aspnet.4guysfromrolla.com/articles/071603-1.aspx Enjoy programming.:)
-
Hi all, I want a help from you. I have an XML file in which i have my database. I want to retrive one record from it based on condition. Like we query the database like "select * from TableName where Name='soandso'". But here my database itself is an XML file. Is it possible in anyway. I have tried navigation but i am stuck. Cant seem to go forward in this. Please help me as soon as possible. Regards, Lavanya:)
hi try to read your xml file into a DataSet, then user the select method for the table inside the DataSet i.e DataSet ds = new DataSet(); ds.ReadXml("Users.xml"); DataRow []arrDR = ds.Tables[0].Select("id=5"); // where id=5 is your condeition and id is a colunm name.
When you get mad...THINK twice that the only advice Tamimi - Code