Output hash-table without @{var=...} when parsing .xml files in Powershell -
i'm new powershell, , trying parse .xml file using code below:
[xml] $alloc_macro = get-content ".\allocation_macro.xml" $newlist = @() foreach ($layer1 in $alloc_macro.dmob.module.macro.block[4].block) { $condition = ($layer1 | select condition) foreach ($layer2 in $layer1.for) { $var = ($layer2 | select var) $in = ($layer2 | select in) $newlist += new-object -typename psobject -property @{ condition = $condition; var = $var; in = $in } } } $newlist
here's result:
condition var in --------- --- -- @{condition=@[allocationflag]} @{var=allocationnumber} @{in=*[eq](##personalnonpersonal##,"personal",@[a... @{condition=*[not](@[allocationflag])}
my question is, can this:
condition var in --------- --- -- @[allocationflag] allocationnumber *[eq](##personalnonpersonal##,"personal",@[a... *[not](@[allocationflag])
thanks!
change this
$condition = ($layer1 | select condition)
to this
$condition = ($layer1 | select -expand condition)
Comments
Post a Comment