February 2019
Intermediate to advanced
626 pages
15h 51m
English
LINQ to XML uses PowerShell to query the content of XML files. This is achieved by combining the methods that are made available through an XDocument (or XContainer or XElement). Methods are available to find attributes and elements, either as immediate children or deeper within a document:
$xDocument = [System.Xml.Linq.XDocument]::Load("$pwd\cars.xml")
$xDocument.Descendants('car').
Where( { $_.Element('colour').Value -eq 'Green' } ).
Element('engine')
The XML-specific methods are supplemented by .Linq extension methods, such as the Where method, to filter content.
As the query a script block encapsulated by the Where method—is native PowerShell, the comparison operation (-eq) is case insensitive. The selection of the element ...
Read now
Unlock full access