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
In a webservice, need to display 10 rows from a table. Which is the best choice among datareader or dataset?
Give an example of what might be best suited to place in the application_start and session_start subroutines?
What are the different kinds of assemblies?
What is a session in asp.net?
Explain asp.net web forms.
In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?
How do we assign page-specific attributes?
how can create login from create and written conde in asp.net
How can we call webservices in Banking Applications? and where we are using it?
Explain the benefits of viewstate?
What threading model used in asp and asp.net?
What is the difference between dynamic SGA and static SGA?
What is difference between mvc and asp.net? : Asp.Net MVC
What is the significance of attaching a profile while creating a user?
How long do session variables last?