[xml]$exampleXML = @"
<servers>
<server name="AAA" />
<server name="BBB" />
<server name="CCC" />
</servers>
"@
# this will match 'AAA'
$exampleXML.SelectNodes("/servers/server[@name='AAA']")
# this will match not 'AAA', because it's looking for 'aaa'
$exampleXML.SelectNodes("/servers/server[@name='aaa']")
# this will match 'AAA' because it translates (i.e. lowercase in this example) the attribute value from 'AAA' to 'aaa' and then matches this with 'aaa'
$exampleXML.SelectNodes("/servers/server[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='aaa']")
Not a blog about plumbing, or Super Mario, but in fact a series of posts about technology, IT and a few other things.
Search This Blog
Tuesday, 10 September 2019
Powershell XML translate for case insensitive attribute value matching
Powershell XML translate to allow attribute values to be matched against values in different cases
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment