snippets / XML processing in C#

Language: C# - First posted by qrist0ph on 2008-04-30 13:10 (5 months, 2 weeks)
Link to the snippet: http://www.friendsnippets.org/snippet/270/

dd

 1  static void Csharp_HelloWorld_XML()
2 {
3 XmlDocument doc = new XmlDocument();
4 XmlNode myRoot;
5 XmlAttribute myAttribute;
6
7
8 myRoot = doc.CreateElement("HelloXMLWorld");
9 doc.AppendChild(myRoot);
10 myAttribute = doc.CreateAttribute("Attribute1");
11 myAttribute.InnerText = "AttributeText1";
12 myRoot.Attributes.Append(myAttribute);
13 //doc.Save(@"c:\helloxmlworld.xml");
14 Console.WriteLine(doc.OuterXml);
15 }
In order to post a comment, you should have a friendsnippet account. Please sign-in.

0 comments

Apr '08

Common Tags



snippet History

Apr '08