Thread: Processing XML
View Single Post
Old 10-21-2008   #1 (permalink)
Jacob
Guest


 
 

Processing XML

I have the following script:

Param(
$prefix,
$volumeTrustees
)


#Load the Trustees files
[xml]$trustees = get-content $volumeTrustees

#Get all the Valid nodes

$validNodes=$trustees.SelectNodes("//Path[starts-with(text(), '$prefix')]/..")

$validNodes | ft


The output is:

subdirectory /apps/Risk/Advisor Switchboard
{User, User, User, User...}
subdirectory /apps/softlogm
{User, User, User, User...}
subdirectory /apps/SuperReport
{User, User, User, User}
subdirectory /apps/Risk/elmapp
{User, User}

And the input looks something like:
<Path>/apps/ABC</Path>
<User
rights="_R____F_">.CN=GJudd.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
<User
rights="_RWC__F_">.CN=AUpchurch.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
<User
rights="_RWCEMF_">.CN=Everyone.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
<User
rights="_R____F_">.CN=RPhillips.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
<User
rights="_RWCEMF_">.CN=Maximus.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
</Trustee_List>
<Trustee_List type="subdirectory">
<Path>/apps/ABC3</Path>
<User
rights="_RWCEMF_">.CN=Maximus.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
<User
rights="_RWCEMF_">.CN=TeamBMH.OU=AllStaff.OU=BRIS.O=BDOK.T=BDOKENDALLS.</User>
</Trustee_List>


My problem is I'd like to select each Path and then list all the 'User'
nodes for that path. I can't help think there is a better way than using
ForEach-object.

--
**********************
Jacob

My System SpecsSystem Spec