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 difference between viewstate and hidden field in asp.net?

0 Answers  


can we call webservice in Html form?

1 Answers   Bank Of America, BirlaSoft, Microsoft,


Difference between mvc2 and mvc3 in asp.net?

4 Answers   Wipro,


What are the advantages of Web API?

0 Answers  


What are the features of asp net?

0 Answers  






What is the difference between <%#%> and <%=%>?

4 Answers   IBS,


What are the different ways you would consider sending data across pages in ASP (i.e between asp to asp)?

0 Answers  


What is ispostback method in asp.net?

0 Answers  


What are the types of validation in asp net?

0 Answers  


Which class provides methods that can be used to manage role membership to be used in user authorization?

3 Answers   Wipro,


How can we Maintain more than on config file in one .Net web application and how?

1 Answers   USi,


difference between <connectionstring> <Appsetting>

6 Answers   VebTel,


Categories