powershell xml xpath

Question!

In Powershell, suppose I have the following xml:

  <Users>
    <User Name="Foo">
      <Friends>
        <Friend Name="Bar"/>
      </Friends>
    </User>
    <User Name="Foo2" />
    <User Name="Foo3">
      <Friends>
        <Friend Name="Bar"/>
      </Friends>
    </User>
  </Users>

How can I get all the users that have a "Bar" as a friend? (In this example it would be Foo,Foo3).

Should I use xpath?

Thanks!



Answers

Yes, XPath would be sufficient for that!

Check Powershell to test your XPath to see how it can be done.



This video can help you solving your question :)
By: admin