What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 13934 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > What is the C# code for XML file by using XmlWriter Class ...
Kamalakanta.Nayak09

What is the C# code for XML file by using XmlWriter Class

Replies: 2 | Posted by: Kamalakanta.Nayak09 on 7/13/2012 | Category: C# Forums | Views: 280 | Status: [Member] | Points: 10  


<SellingStatus>
<ConvertedCurrentPrice currencyID="USD">153.68</ConvertedCurrentPrice>
<CurrentPrice currencyID="GBP">99.0</CurrentPrice>

</SellingStatus>

What is the C# for above xml by using the XmlWriter Class?
I want code specially for <ConvertedCurrentPrice currencyID="USD">153.68</ConvertedCurrentPrice>
It is urgent for me.

Thanks,
K.K


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Premalatha
Premalatha  
Posted on: 7/13/2012 4:35:04 AM
Level: Starter | Status: [Member] | Points: 25

http://www.dotnetperls.com/xmlwriter

Premalatha
Software Engineer

Kamalakanta.Nayak09, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Premalatha
Premalatha  
Posted on: 7/13/2012 4:37:18 AM
Level: Starter | Status: [Member] | Points: 50

Resolved

using System;
using System.Text;
using System.Xml;

namespace WritingXml
{
class Program
{
static void Main(string[] args)
{
XmlWriter xmlWriter = XmlWriter.Create("test.xml");

xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("users");

xmlWriter.WriteStartElement("user");
xmlWriter.WriteAttributeString("age", "42");
xmlWriter.WriteString("John Doe");
xmlWriter.WriteEndElement();

xmlWriter.WriteStartElement("user");
xmlWriter.WriteAttributeString("age", "39");
xmlWriter.WriteString("Jane Doe");

xmlWriter.WriteEndDocument();
xmlWriter.Close();
}
}
}
The above code will create the following XML:
<users>
<user age="42">John Doe</user>
<user age="39">Jane Doe</user>
</users>

Premalatha
Software Engineer

Kamalakanta.Nayak09, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 6:09:50 AM