public void AddToXml(System.Xml.XmlNode xmlNode) { // System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer( System.Xml.XmlDocument doc; if (xmlNode.GetType() == typeof(System.Xml.XmlDocument)) { doc = (System.Xml.XmlDocument)xmlNode; } else { doc = xmlNode.OwnerDocument; } for (int i = 0; i < this.ChildNodes.Count; i++) { System.Xml.XmlNode xmlNew; Node child = (Node)this.ChildNodes.GetByIndex(i); try { xmlNew = doc.CreateElement(child.Name); } catch { xmlNew = doc.CreateElement("IncorrectXmlName"); } if (child.Value != null) { System.Xml.XmlAttribute attrib = doc.CreateAttribute("value"); attrib.InnerText = child.Value.ToString(); xmlNew.Attributes.Append(attrib); } xmlNode.AppendChild(xmlNew); child.AddToXml(xmlNew); } }