I have this type of XML schema of User/Roles
<Department/>
<JobTitle/>
<Language/>
<Roles>
<UserRole public-id="pc:2001">
<Role public-id="superuser"/>
<User public-id="system:44"/>
</UserRole>
<UserRole public-id="usrrol:48">
<Role public-id="underwriter_supervisor"/>
<User public-id="system:44"/>
</UserRole>
<UserRole public-id="usrrol:49">
<Role public-id="user_admin"/>
<User public-id="system:44"/>
</UserRole>
</Roles>
I want to search on nodes UserRole.User on the attribute public-id >> Like system:44 which I have in a variable (this identifies the user).
Then return all text values for UserRole.Role attribute public-id >> Like "user_admin". The UserRole is the associated parent of the first search.
I tried dot notation like below, but powershell seems to not like the reference to $user.public-id. I get a parsing error 'FullyQualifiedErrorId'
foreach ($user in $xml.import.User.Roles.UserRole.User) {
if ($user.public-id -eq 'system:44') {
$userRole = $user.GetParent
write-host "Role - " $userRole.Role.publid-id
}
}