write a sample code make use of xmltext writer

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of session in asp.net?

534


Explain the different types of directives in .net?

525


What is authorization in asp.net?

587


What’s the catch?

632


List the major built-in objects in asp.net?

553






COM+ Used ________________ Isolation Level

1532


What is ascx?

541


Explain what is the procedure to create the environment for asp.net? : asp.net mvc

551


We are using Jscriopt validations and at clint site javascript is not running that time validation would work? if yes then how it would behave?

1414


What is a windows service?

568


What are the different types of Caching techniques in ASP.NET?

588


What are custom user controls in asp.net?

530


Is asp.net outdated?

542


What are sessions in asp net?

531


When should I use server transfer and response redirect?

526