Subscribe to Windows IT Pro
September 15, 2010 12:01 AM

Q. Can PowerShell read and parse XML files?

Windows IT Pro
InstantDoc ID #125887
Rating: (6)

A. Yes, although the means isn't very obvious. If you have an XML file named Mine.xml, do this:

[xml]$xml = Get-Content Mine.xml

That'll read the file, parse the XML, and construct within the $xml variable an object tree based on the XML structure. Run

$xml | Get-Member

to see the root of the object hierarchy. For more information, see the great post "Processing XML with PowerShell" and the introductory tutorial "PowerShell and XML".

 

Do you have a Windows PowerShell question? Why not submit it to Don? Post your question at windowsitpro.com/go/SubmitFAQ and you might see your answer online! Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.