AppendNode

public static void AppendNode<T>(this XmlElement root, string name, T value)
{
  XmlDocument doc = root.OwnerDocument;
  if (doc != null)
  {
    XmlElement code = doc.CreateElement(name);
    XmlText codeText = doc.CreateTextNode(value.ToString());
    root.AppendChild(code);
    code.AppendChild(codeText);
  }
}
Example:
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("Root");
doc.AppendChild(root);
root.AppendNode("Child 1 Name", "Child 1 Value");
root.AppendNode("Child 2 Name", 123);

Description

Append new child XmlElement to base XmlElement.

Details

Double click on the code to select all.

 

;