Iterate through nodes of multiple XML files — with PowerShell

Barnabás Nagy
1 min readJul 24, 2019

Sometimes I need a quick script to read all specific tags in a plenty of XML files and make a report of them — e.g. show which nodes have the same values in a given attribute like an ID. Instead of writing a .net app, this task can be solved simply by PowerShell as well.

First, we have a batch of XML files in a folder. These XLIFF files in may case, so included all files with extension starting by x char.

Then let just list the IDs of each <trans-unit> tags:

If you have different XML structure and different nodes, let’s modify the trailing part after $d in the #7 line.

The script above also group the result by the values of IDs. This is useful when you want to list only the duplicated IDs — just add “| where count -ge 2”:

We can even make the IDs unique and save the files with one more small modification:

--

--

Barnabás Nagy

I’m an intl PM in localization, BI Developer and a certified Google Professional Data Engineer. My hobby projects: Data apps, open source apps and DIY stuffs