February 2019
Intermediate to advanced
626 pages
15h 51m
English
The XML type accelerator ([Xml]) can be used to create instances of XmlDocument, as shown in the following code:
[Xml]$xml = @"
<?xml version="1.0"?>
<cars>
<car type="Saloon">
<colour>Green</colour>
<doors>4</doors>
<transmission>Automatic</transmission>
<engine>
<size>2.0</size>
<cylinders>4</cylinders>
</engine>
</car>
</cars>
"@
Elements and attributes of an XmlDocument object may be accessed as if they were properties. This is a feature of the PowerShell language rather than the .NET object:
PS> $xml.cars.car type : Saloon colour : Green doors : 4 transmission : Automatic engine : engine
If the document contains more than one car element, each of the instances will be returned.
Read now
Unlock full access