February 2019
Intermediate to advanced
626 pages
15h 51m
English
The XDocument class is used to load or parse a document. XML content may be cast to an XDocument in the same way that content is cast using the [Xml] type accelerator:
[System.Xml.Linq.XDocument]$xDocument = @"
<?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>
"@
$xDocument.Save("$pwd\cars.xml")
If the content has been saved to a file, the Load method may be used with a filename:
$xDocument = [System.Xml.Linq.XDocument]::Load("$pwd\cars.xml")
Read now
Unlock full access