can we add questions and answers into database using xml?

Posted by Tejamanimala under ASP.NET on 4/16/2013 | Points: 10 | Views : 1027 | Status : [Member] | Replies : 3
how can we add questions into database using xml in asp.net

manimala


Responses

Posted by: Sandeepmhatre on: 4/16/2013 [Member] Starter | Points: 25

Up
0
Down
can you explain with example ?

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 4/16/2013 [Member] Starter | Points: 25

Up
0
Down
for online examination,i want to add questions.actually admin will add the questions into database,when student comes for online test we want to retrieve it from database,and calculate the marks for that questions and answers.actually i wrote code for this,but not using xml,i added the questions into database directly and retrieve it from database.but i want to upload xml file for question paper,means at time i want to add 30 questions .

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 4/16/2013 [Member] Starter | Points: 25

Up
0
Down
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

Login to post response