Parsing XML within subfolders

Hello All,

I am new to Powershell and need some help.

I have a folder with many xml files inside sub folders. I want to go through all the folders and look for file name with ABC.xml and search for a tag with key “TestTag” and if it exists get the value of that key.


The folder D:/TestFolder has subfolders and the file ABC.xml exists under D:/TestFolder/TestingFiles which has key “TestTag” as below

<myTag id="key">Testing</myTag>
<myTag id="value">testValue1</myTag>
<myTag id="key">TestTag</myTag>
<myTag id="value">MyValue</myTag>
<myTag id="key">OneTwoThree</myTag>
<myTag id="value">true</myTag>
<myTag id="key">ThisIsNot</myTag>
<myTag id="value">testValue2</myTag>

Output Expected:

FilePath --> D:D:/TestFolder/TestingFiles and Value --> MyValue

Welcome to the forum. :wave:t4:

What kind of help do you need?

Please keep in mind - this forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

What have you tried so far? We expect you to make an own attempt to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

To get you started you may read the help for the following help topics. Please read them completely including the examples to learn how to use them: