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
Which method is used to perform all validation at the page level?
What is asp.net used for?
How will create assesblies at run time?
What is asp.net architecture?
What is the difference between an htmlinputcheckbox control and an htmlinputradiobutton control?
How many web config files can be created for an application?
Can a master page have more than one contentplaceholder?
1.what is the application pool. 2.what is the HttpModile and Http Handler. 3.C# 3.0 Features ? 4.Anonoymous Type,methopd and claas in 3.0? 5.difference between statsic and const ? 6.session vs application 7.state management clint side and server side ? 8.Genric list 9.c# 3.0 vs 3.5
How does asp net store session ids by default?
Which is faster union or union all?
Where code pages are used?
Define repository pattern in asp.net mvc? : asp.net mvc
what is DLL Hell and how it is solved in .NET? please explain clearly??
Why cyclomatic complexity is important?
Explain the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc