// vytvoen objektu typu XmlDocument
XmlDocument customerDocument = new XmlDocument();

// zadn instrukce pro zpracovn a zaloen elementu dokumentu (koenov element)
customerDocument.AppendChild(customerDocument.CreateProcessingInstruction
	("xml", "version='1.0' encoding='UTF-16' standalone='yes'"));
customerDocument.AppendChild(customerDocument.CreateElement("customer"));
customerDocument.DocumentElement.SetAttribute("id", "C01");

// vytvoen a pidn podzenho elementu "firstName" do elementu dokumentu
XmlElement firstNameElement = customerDocument.CreateElement("firstName");
firstNameElement.InnerText = "Paolo";
customerDocument.DocumentElement.AppendChild(firstNameElement);

// vytvoen a pidn podzenho elementu "lastName" do elementu dokumentu
XmlElement lastNameElement = customerDocument.CreateElement("lastName");
lastNameElement.InnerText = "Pialorsi";
customerDocument.DocumentElement.AppendChild(lastNameElement);

// vytvoen elementu "addresses"
XmlElement addressesElement = customerDocument.CreateElement("addresses");

// vytvoen a pidn podzenho elementu "emailov adresa" do elementu "addresses" 
XmlElement emailAddressElement = customerDocument.CreateElement("address");
emailAddressElement.SetAttribute("type", "email");
emailAddressElement.InnerText = "paolo@devleap.it";
addressesElement.AppendChild(emailAddressElement);

// vytvoen a pidn podzenho elementu "adresa url" do elementu "addresses" 
XmlElement urlAddressElement = customerDocument.CreateElement("address");
urlAddressElement.SetAttribute("type", "url");
urlAddressElement.InnerText = "http://www.devleap.it/";
addressesElement.AppendChild(urlAddressElement);

// vytvoen a pidn podzenho elementu "adresa bydlit" do elementu "addresses" 
XmlElement homeAddressElement = customerDocument.CreateElement("address");
homeAddressElement.SetAttribute("type", "home");
homeAddressElement.InnerText = "Brescia - Italy";
addressesElement.AppendChild(homeAddressElement);

// pidn podzenho elementu "addresses" do elementu dokumentu
customerDocument.DocumentElement.AppendChild(addressesElement);
