Formating XML content


i  trying shred xml document , formatting needed info. have following xml:

<drives>
<drive>
status="active"
<properties>
label="d drive"
</properties>
<filter>
<filteruser>
name="greg" bool="or" name="fred"
</filteruser>
</filter>
</drive>

<drive>
status="active"
<properties>
label="a drive"
</properties>
<filter>
<filtergroup>
name="mike" bool="or" name="frederick"
</filtergroup>
</filter>
</drive>

<drive>
status="active"
<properties>
label="a drive"
</properties>
<filter>
<filtergroup>
name="laurent" bool="or" name="frederick" bool="or" name="gomez"
</filtergroup>
</filter>
</drive>
</drives>

ideally following:

label name membership

active d drive greg or fred

active a drive mike or frederick

active a drive laurent or frederick or gomez

i imported xml content array. having hard time formatting array content tale, multidimensional array. let me know if there missing.

hi,


pls check following links powershell , xml. there many others too.

http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/25/the-scripting-wife-learns-to-use-powershell-to-work-with-xml.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/13/use-powershell-to-simplify-access-to-xml-data.aspx

a quick try :)

([xml](get-content .\testxml.txt)).drives.drive | select @{n='status'; e={ $_.'#text'.split("`n=")[2]}}, @{n='label'; e= {$_.properties.split("`n=")[2]}}, @{n='membership'; e= { ($_.filter.innertext.split("`n")[1]  -replace '[^"]*"([^"]+)"[^"]*', '$1 ' )}}


rgds,



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607