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 is clr? Difference between clr & cts?

860


Explain server-side scripting?

766


What is intrinsic objects in asp.net?

854


What is directive in asp net?

736


8. Why do you want to work here?

1653


What is the state management in asp.net?

739


What is a web server? What are the load limits in it?

787


List all templates of the repeater control.

747


How can you apply a theme to your asp.net application?

725


What is a SESSION and APPLICATION object?

765


Out of ASP or ASP.NET which one is stateless?

890


What is the difference between cookie and session?

695


Is there any limit for query string? Means what is the maximum size?

694


Which method is used to perform all validation at the page level?

721


Explain form level validation and field level validation?

755