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 contained more than one car element, each of the instances will be returned.