XML type accelerator

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.236.62