Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create a Simple XML Document in C#
This is an example demonstrating how to create a simple XML document in C#. // This code creates XML that looks like this:
/*
* <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
* <rootNode>
* <firstChild color="orange" speed="fast">This is the first child</firstChild>
* <secondChild>
* <grandChild>This is the grandchild</grandChild>
* </secondChild>
* </rootNode>
*
* */
private void CreateXML_Click(object sender, System.EventArgs e)
{
Chilkat.Xml doc = new Chilkat.Xml();
doc.Encoding = "utf-8";
doc.Standalone = true;
doc.Tag = "rootNode";
Chilkat.Xml firstChild = doc.NewChild("firstChild","This is the first child");
firstChild.AddAttribute("color","orange");
firstChild.AddAttribute("speed","fast");
Chilkat.Xml secondChild = doc.NewChild("secondChild","");
Chilkat.Xml grandChild = secondChild.NewChild("grandChild","This is the grandchild");
doc.SaveXml("simple.xml");
textBox1.Text = doc.GetXml();
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.