Create XMl

How to create xml

To create xml we need to do following steps=>

1)First include the name i)System.Xml ii)System.IO iii)System.Text.

2)create writer object

>XmlTextWriter writer = new XmlTextWriter(Server.MapPath(“xml/userInfo.xml”), Encoding.UTF8);
In Server.MapPath we specify the path where we would like to create xml file.
statr to write by writer.WriteStartDocument();
writer.WriteStartElement(“userInfo”); this specify strat element with element userInfo
writer.WriteElementString(“urlReferrer”, “none”);this specify sub element with element urlReferrer and value none
writer.WriteAttributeString(“timeVisited”, DateTime.Now.ToString());this specify a element attribute with timeVisited
writer.WriteEndElement(); this specify end of a element
writer.WriteEndDocument(); this specify end of a document.
writer.Close(); this specify close of a document.
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.