Reputation: 924
I have three nodes with the same name but with different attributes. I would like to only select the one where the bar attribute exists.
<Test foo="Hello" />
<Test bar="World" />
<Test zed="Goodbye" />
Upvotes: 0
Views: 158
Reputation: 174435
You could use XPath for this:
Select-Xml -Path path\to\file.xml -XPath '//Test[@bar]'
//Test
will resolve any <Test>
nodes anywhere in the tree, [@bar]
filters them by whether they have a bar
attribute or not
Upvotes: 2