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

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL