using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
namespace BindGridView
{
public partial class XMLWriting : System.Web.UI.Page
{
//SqlConnection objcon = new SqlConnection("data source=SQLEXPRESS;database=studentDB;uid=so;pwd=123;");
SqlConnection con = new SqlConnection("server=ECC_12\\SQLEXPRESS;Integrated security=True;Initial catalog=ontoxmly");
//SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
try
{
XmlTextWriter xmlwriter = new XmlTextWriter(Server.MapPath("XMLNodeFile.xml"), System.Text.Encoding.UTF8);
xmlwriter.WriteStartDocument(true);
xmlwriter.Formatting = Formatting.Indented;
xmlwriter.Indentation = 2;
xmlwriter.WriteStartElement("owl");
xmlwriter.WriteStartElement("contexttype");
DataTable objdt = new DataTable();
string query = "select * from ontosamp;";
SqlDataAdapter objda = new SqlDataAdapter(query,con);
con.Open();
objda.Fill(objdt);
con.Close();
if (objdt.Rows.Count > 0)
{
for (int i = 0; i < objdt.Rows.Count; i++)
{
XMLNodeCreator(objdt.Rows[i]["data"].ToString(), xmlwriter);
//objdt.Rows[i]["Address"].ToString(), objdt.Rows[i]["Marks"].ToString(), objdt.Rows[i]["ContactNo"].ToString(),
}
}
xmlwriter.WriteEndElement();
xmlwriter.WriteEndElement();
xmlwriter.WriteEndDocument();
xmlwriter.Close();
lblmessage.Text = "Xml created successfully.";
}
catch (Exception ex)
{
lblmessage.Text = "Error :"+ex.Message.ToString();
}
}
private void XMLNodeCreator(string Name, string Address, string Marks, string ContactNo, XmlTextWriter xmlwriter)
{
xmlwriter.WriteStartElement("employe");
xmlwriter.WriteStartElement("data");
xmlwriter.WriteString(data);
xmlwriter.WriteEndElement();
}
}
}
---------------------------------------------------------------------------------------------------------------------------
It display this error,
Could not load type 'BindGridView.XMLWriting'