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

Explain an object, class and method.

0 Answers  


on modify statement, executeNonQuery returns zero rows affected even though there has been modification carried out sucessfully in the table.. can anyone tell me is this possible??? if yes, how..???

1 Answers   ADITI,


What are validator? Name the Validation controls in asp.net? How do u disable them?

2 Answers  


How many types of file extensions for razor views in ASP.Net MVC?

0 Answers  


What are the different types of events are occured when a client requests an ASP.NET page from IIS server?

0 Answers   Sans Pareil IT Services,


Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?

2 Answers   Siebel Systems,


To display data in a Repeater control which template you provide?

0 Answers   Siebel,


Which is an advantage of application service providers?

0 Answers  


If Instancing = Single use for ActiveX Exe, how will this be executed if there are 2 consecutive client requests ?

0 Answers   DELL,


What is viewstate? What does the “enableviewstate” property do?

0 Answers  


Describe the diffeerence between inline and code behind?

0 Answers  


What are the events in a page life cycle?

0 Answers  


Categories