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 language does asp.net use?

0 Answers  


What is asp.net response object?

0 Answers  


What are the types of authentications in ASP.NET?

2 Answers   Accenture, BirlaSoft,


What is the role of global.asax?

10 Answers   Infosys,


Explain model, view and controller represent in an mvc application? : asp.net mvc

0 Answers  


how to stop cookie in particular page using asp.net

2 Answers   CGI,


What are different types of directives in .NET ?

1 Answers  


What is asp.net used for?

0 Answers  


Explain the overview of asp.net?

0 Answers  


what is the assembly?

2 Answers  


Caching techniques in .NET?

2 Answers   Microsoft,


Differentiate between structure and class.

0 Answers  


Categories