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

How .Net has implemented security for web applications?

1 Answers  


What is the use of worker process in asp.net?

0 Answers  


List the types of authentication supported by asp.net?

0 Answers  


What are the differences between primary foreign and unique keys?

0 Answers  


Explain the difference between response.redirect vs server.transfer

0 Answers  






difference between writing connection string in web.config through connection string and appsettings

2 Answers   iSoft,


Which adapter should you use, if you want to get the data from an access database?

0 Answers  


How to improve performance of web application asp.net mvc? : Asp.Net MVC

0 Answers  


Differentiate between file-based dependency and key-based dependency.

0 Answers  


Given an ASP.NET Web Form called WebFrom1, what class does the WebForm1 class inherit from by default? a) System.Web.Form b) System.Web.GUI.Page c) System.Web.UI.Page d) System.Web.UI.Form

3 Answers   Syntax Softtech,


Why Unload event of MasterPage Calls first in ASP.net ?

0 Answers   HCL,


what is view state and its use

10 Answers   DELL, Efextra, HCL,


Categories