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
Explain what benefit does your code receive if you decorate it with attributes demanding specific security permissions?
Can we use html in asp.net?
What is web api config?
In which event of the page viewstate is available?
Can I read the hard disk serial # of the client computer using asp.net?
What is the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc
Can you explain page lifecycle in net?
What is difference between asp.net and asp?
What tags do you need to add within the asp:datagrid tags to bind columns manually? How?
What is data binding in asp net?
How to make paging concepts in datagrid in ASP.NET?
What does mvc represent in asp.net? : asp.net mvc
Which is better union or union all?
Explain difference between dataset and recordset?
Can we use a static function with a non-static variable?