February 2019
Intermediate to advanced
626 pages
15h 51m
English
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 method of the XmlDocument (held in the $xml variable).
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.
Read now
Unlock full access