write a sample code make use of xmltext writer



write a sample code make use of xmltext writer..

Answer / career.tina@yahoo.co.in

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
//creating a apth for writing xml
string xml1 = Server.MapPath("test2.xml");
//initialising xmlwriter
XmlTextWriter xt = new XmlTextWriter(xml1,
System.Text.Encoding.UTF8);
xt.Formatting = System.Xml.Formatting.Indented;
//start writing it
xt.WriteStartDocument();
//element
xt.WriteStartElement("name");
// attribute
xt.WriteAttributeString("my_name", "name");
xt.WriteStartElement("phn");
xt.WriteAttributeString("my_phn", "266549560");
xt.WriteStartElement("id");
xt.WriteAttributeString("my_id", "100");
xt.WriteStartElement("city");
xt.WriteAttributeString("my_city", "city");
xt.WriteElementString ("title","gud girl");
//ending all elements
xt.WriteEndElement ();
xt.WriteEndElement();
xt.WriteEndElement();
xt.WriteEndElement();
xt.WriteEndDocument();
xt.Close ();

}
catch
{
}

}
}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

what is managed and unmanaged code?

4 Answers   Microsoft,


What is localization and Globalization?

3 Answers  


What is Forms Authentication in ASP.NET?

0 Answers  


What is indexing on asp.net?

0 Answers  


What is asp.net file?

0 Answers  






What is asp.net caching?

0 Answers  


Where is the view state data stored?

0 Answers  


Give some salient points of difference between request processor and request dispatcher.

0 Answers   Tech Mahindra,


What is rending process in ASP.NET?

0 Answers   Sans Pareil IT Services,


Hi, I am a fresher. i have a problem related to DataGrid . i have a data grid and i have to place a dropdown in the datagrid.and i have to retrieve the values from the database (sqlserver).please tell me any idea about the code.

1 Answers   Lambent,


How many types of web application ?

1 Answers  


I have been asked in an interview What is your LOC(Line of Code)What will be the probable answer for that

1 Answers   HCL, Infosys, Mantec Consultants,


Categories