I have an XML File where root elements have a nested tag to identify the node. How could I grab the node by the specific tag contained within the root element?
Below I have tag named "master", which can contain "old" or "new" value. How could I grab just "new"?
Sample File:
<xml>
<foo>
<master>New</master>
<data>
<val1>Value</val1>
</data>
</foo>
<foo>
<master>Old</master>
<data>
<val1>Value</val1>
</data>
</foo>
</xml>
Select-XML does not work because sometimes the file has tags the are not closed.
With this code, I can get val1 from both nodes
[xml] $xml = Get-Content "$file"
$xml.xml.foo.data
I tried
$xml.xml.foo.data.val1 | Where-Object ($xml.xml.foo.master -eq "New")
and I tried
if ($xml.xml.foo.master -eq "New") {$xml.xml.foo.data.val1}
Sorry if my xml terminology doesn't make sense.