![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
|
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Processing XML On Oct 21, 2:18*am, Jacob <jacob(AT)hfws.net.nospam> wrote:
$validNodes|%{$t=$_.Path;$_.User|write-host $t,$_} The key to nesting foreach pipelines (i.e. pipelines with %{}) is to store the $_ value (or the part of it you need) in a temp variable before creating the nested one. It's also possible to access the parent scope of $_ but I usually consider that just too messy to bother with. | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: Processing XML RickB wrote:
foreach ( $node in $validNodes ) { $node.User | % { $node.Path, $_ } } is one example... -- $signature = "Hal Rottenberg, MVP - Admin Frameworks" $projects = @{ title = "Blog Author"; url = "http://halr9000.com" }, @{ title = "Co-host"; url = "http://powerscripting.net" }, @{ title = "Community Director"; url = "http://PowerShellCommunity.org" }, @{ title = "Psi Webmaster"; url = "http://psi-im.org" } | ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Processing XML Thanks guys that did the trick. -- ********************** Jacob "Hal Rottenberg [MVP]" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
|
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need a technique to speed up processing | dang57 | .NET General | 5 | 10-09-2008 01:17 PM |
| Log In Out File Processing | TimParker | PowerShell | 5 | 09-04-2008 08:10 PM |
| Asynchronous Processing | Ozone | PowerShell | 7 | 06-09-2008 10:27 AM |
| More text processing. | Kryten | PowerShell | 5 | 12-17-2007 09:02 PM |
| ACT! Word Processing Problem? | P Fruin | Vista General | 1 | 11-19-2007 06:24 PM |