SQL Server 2005 and up have a datatype called "XML" which you can store XML in - untyped or typed with a XSD schema.
You can basically fill columns of type XML from an XML literal string, so you can easily just use a normal INSERT statement and fill the XML contents into that field.
You can then bind that XML to your data controls using following technique:
XmlNode Result = obj.GetXMLData();
if ((Result != null) & Result.InnerXml.Length > 0)
{
XmlTextReader objXmlTextReader = new XmlTextReader(Result.OuterXml, XmlNodeType.Element, null);
DataSet objDataSet = new DataSet();
objDataSet.ReadXml(objXmlTextReader);
GridView.DataSource = objDataSet.Tables[3].DefaultView;
GridView.DataBind();
}
Or if you have XML file of Questions in any ASP.Net folder, then it gets easier; use following code :
/*You have to Convert the Xml data to DataTable first and bind that DataTable object to GrideView */
DataTable dt = new DataTable();
dt.ReadXml(@"filepath.xml");
GridView1.DataSource = dt;
GridView1.DataBind();
Note: You need to take some pain from your side since i have newa tried this :)
http://hashtagakash.wordpress.com/
Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator