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
Why mvc is better than asp.net? : Asp.Net MVC
What are the navigation ways between pages available in ASP.NET?
Explain the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc
What is session authentication?
Which .NET framework supports Web API?
Is asp.net and .net are same or different?
What is a 404 redirect?
What r the asp.net list controls and difference between them?
What kind of data can be stored in viewstate?
What are server objects?
How do I upload a file from my ASP.NET page?
Where viewstate value is stored in asp.net?
Is it possible to develop a single web application using ASP.NET webforms and ASP.MVC?
What is authorization in asp.net?
What are the authentication types in asp.net?