September 13th, 2012

PowerTip: Use PowerShell to Easily Read an XML Document

Doctor Scripto
Scripter

Summary: Use the [xml] type accelerator to greatly simplify reading XML documents.

Hey, Scripting Guy! Question How can I easily read an XML file?

Hey, Scripting Guy! Answer Use the [XML] type accelerator to convert results from Get-Content into an XML document, and then use dotted notation to access the nodes:

[xml]$books = Get-Content C:\fso\Books.XML

$books.catalog.book.title

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback