Given XML like this...
<Rule scope="node">
<Property>regKeyExists</Property>
<Path>HKLM\SOFTWARE\MozillaPlugins\ K:@microsoft.com/GENUINE</Path>
<Operator>-eq</Operator>
<Value>true</Value>
</Rule>
<Or scope="node">
<Rule>
<Property>regKeyExists</Property>
<Path>HKLM\SOFTWARE\MozillaPlugins\ K:@microsoft.com/GENUINE</Path>
<Operator>-eq</Operator>
<Value>true</Value>
</Rule>
</Or>
...but which could have nodes other than <Rule> and <Or>, and could have values for Scope other than "node", I am trying to select just the Rule and Or nodes where scope=node.
Currently I am using $nodes = $xml.SelectNodes("./*[@scope='node']") then looping with foreach ($node in $nodes) and checking $node.name so I can work with just the Rule and Or nodes. But my preference would be to do it with XPath. I have found reference to using or in predicate expressions, but only with attributes, not with node names.
This XPath,
//*[self::Rule or self::Or][@scope='node']
will select all Rule or Or elements with @scope attribute values of 'node'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With