Last year I took part in PowerShell Community Konferenz that took place in Essen/ Ruhr and was total blast. The only issue I had with last year event was the fact that my German is… as good as my Dutch. So unless German session was full of demos and code – I was not able to follow it. Fortunately, most of the sessions were actually of the kind I could follow even if they were presented in languages I hadn’t heard in my life. I can read code, even if variables may seem obfuscated. Apart from that there was very nice line-up of people who presented in English, including super-stars of my PowerShell world like Aleksandar Nikolić or Bruce Payette.
PowerShell is not case sensitive (most of the time). There are two situation when it is: you explicitly request it (e.g. using operators like –cmatch) or we depend on something where there is no easy way to turn it off. Select-Xml is using XPath and falls in the second category. Whenever I need to query large XML file I prefer to start with more general queries, and there is very few things more frustrating than being forced to remember case of e.g. attribute names. There are two options to go about it.
First of all we can do it easy way: change case of the whole string that defines XML, and be sure, that everything is either lower or upper case. Problem with this approach is the fact, that result we get back is different from original, and we are bit “stuck” with “broken” XML.
Second option is to use XPath own tools to get similar results, and has advantage of getting “proper” XML data back. Using Select-Xml also enables modifying XML and saving under different name.