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 is the cursor

1 Answers   Wipro,


Code for updating the database by entering the data into textboxes in aspx form?

2 Answers   TCS, Wipro,


what is session ?how sessions are handeled in application? write the clauses of sql server in their order.

3 Answers   Olive Tech,


How can we prevent browser from caching an aspx page?

0 Answers  


Where does the Web page belong in the .NET Framework class hierarchy?

1 Answers  






Is There any Third party tools are using in .Net Technologies? Can u Explain?

4 Answers   HCL,


What is cross page posting? How is it done?

0 Answers  


Explain difference between friend and protected friend?

0 Answers  


Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). Which one is trusted and which one is untrusted?

3 Answers  


What are session cookies?

0 Answers  


What does mvc represent in asp.net? : asp.net mvc

0 Answers  


what is aspcompat? what it does?

1 Answers  


Categories