Sunday, July 27, 2008

How to Querying XML raw data

This code snippet for loading XML file in to Dataset and then querying particular record as we practising on SQL-Query.

DataSet ds = new DataSet();
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(File.ReadAllText(@"E://Form.xml"));
ds.ReadXml(new XmlNodeReader(xDoc));
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["ID"].Equals(TextBox1.Text))
{
Response.Write(dr["txtControlName"].ToString() + "\t");
Response.Write(dr["lblControlName"].ToString());

}


}