How to recursively get nested properties from an XML file
i recursively properties in xml document powershell. find can load document following example $xml_file path file want work on.
$xml_object = [xml](get-content $xml_file)
once there can properties following example , results.
$xml_object | get-member -membertype properties
typename: system.xml.xmldocument
name membertype definition
---- ---------- ----------
showplanxml property system.xml.xmlelement showplanxml {get;}
xml property system.string xml {get;set;}
but can see property may has properties. want run get-member find properties. can go on many levels , don't know how deep go. i've been trying combine use of get-childitem -recurse , get-property no avail , think must missing obvious.
any advice or guidance on recursively getting nested properties welcome.
joe moyle
to retrieve values of xml file whatever purpose might better use usual tools of system.xml assembly, example follows:
$xml = [xml](gc $xml_file) $tmp = $xml.selectnodes("//*") $cnt = $tmp.count ($i = 0; $i -lt $tmp.count; $i++) { $tmp.item($i).innertext }
kind regards,
wizend
Windows Server > Windows PowerShell
Comments
Post a Comment