February 2019
Intermediate to advanced
626 pages
15h 51m
English
Existing elements in an XML document can be modified by assigning a new value. For example, the misspelling of Appliances could be corrected:
[Xml]$xml = @"
<?xml version="1.0"?>
<items>
<item name='Fridge'>
<category>Appliancse</category>
</item>
<item name='Cooker'>
<category>Appliances</category>
</item>
</items>
"@
($xml.items.item | Where-Object name -eq 'Fridge').category = 'Appliances'
Attributes may be changed in the same way; the interface does not distinguish between the two value types.
A direct assignment of a new value cannot be used if the XML document contains more than one element or attribute with the same name (at the same level). For example, the following XML snippet has two values ...
Read now
Unlock full access