| 
using System;
using System.Xml;
  public class XmlDocumentExample2 {
    public static void Main(String[] argv) {
      //----- create the root element �addressbook�
      XmlElement rootElem = doc.CreateElement("addressbook");
      rootElem.SetAttribute("owner", "1");
      doc.AppendChild(rootElem);
      //----- create a �person� element
      XmlElement person = doc.CreateElement("person");
      person.SetAttribute("id", "1");
      XmlElement e = doc.CreateElement("firstname");  // first name
      e.AppendChild(doc.CreateTextNode("Wolfgang"));
      person.AppendChild(e);
      e = doc.CreateElement("lastname");  // last name
      e.AppendChild(doc.CreateTextNode("Beer"));
      person.AppendChild(e);
      e = doc.CreateElement("email");  // e-mail address
      e.AppendChild(doc.CreateTextNode("beer@uni-linz.at"));
      person.AppendChild(e);
      doc.DocumentElement.AppendChild(person);
      //----- create further �person� elements ...
      ...
      //----- test output on the console
      doc.Save(Console.Out);
    }
  } |