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 |
What are Http handler ?
6 Answers Accenture, BirlaSoft, Satyam, Syntel,
what is the challenging situation you faced in your career?
3 Answers Calsoft, HP, Satyam, Wipro,
How Can we use multiple forms in single asp.net application?
What is diff. Between abstract class and an interface?
what exception is thrown when you do a response.redirect
What is the difference between User Controls and Master Pages
22 Answers Deloitte, IBM, IntraLogic, Markit, TCS,
How many types of file extensions for razor views in ASP.Net MVC?
web farm .. how does session shuld be stored... if inproc used? does the session persists from one server to other.
Can private assembly be used for more than one application? If so how?
Describe Segmentation With Paging?
What is Hidden Fields in Asp.Net
One Listbox showing all cities. If you select one city in list box the information related to that particular city should be displayed in Datagrid . How do you do that?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)