How to get the parent node of a given child node using PowerShell?
- by kumar
I am new to PowerShell. I have to write a script which can return me the first parent(node) value by passing the child node.
I have the following XML. When I pass my PowerShell script the value "AAA", it should return "parent2", and when I pass "III", it should return "parent311".
Can someone help me write this script?
XML:
<root>
<parent>
<parent2>
<child>AAA</child>
</parent2>
<parent3>
<child>BBB</child>
<child>CCC</child>
<child>DDD</child>
</parent3>
<parent4>
<child>EEE</child>
</parent4>
<parent5>
<child>FFF</child>
</parent5>
</parent>
<parent21>
<parent211>
<child>GGG</child>
</parent211>
<parent311>
<child>HHH</child>
<child>III</child>
<child>JJJ</child>
</parent311>
<parent411>
<child>KKK</child>
</parent411>
<parent511>
<child>LLL</child>
</parent511>
</parent21>
</root>