October 2017
Intermediate to advanced
440 pages
11h 47m
English
Existing elements within 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 ...
Read now
Unlock full access