Elements must be created before they can be added to an existing document. Elements are created in the context of a document:
[Xml]$xml = @" <?xml version="1.0"?> <list type='numbers'> <name>1</name> </list> "@ $newElement = $xml.CreateElement('name') $newElement.InnerText = 2 $xml.list.AppendChild($newElement)
Complex elements may be built up by repeatedly using the Create methods of the XmlDocument (held in the variable, $xml).
If the new node is substantial, it may be easier to treat the new node set as a separate document and merge one into the other.