Home > powershell, xml > xml and powershell

xml and powershell

January 24th, 2011 Leave a comment Go to comments

I wrote about the unix command-line utility xmllint there : extract xml from the command line

Let’s do the same exercice in Powershell


PS> gc foo.xml
<emplist>
  <emp no="1">
    <ename>John</ename>
  </emp>
  <emp no="2">
    <ename>Jack</ename>
  </emp>
</emplist>

Simply use [xml] datatype !

(([xml](GC foo.xml)).emplist.emp|Where{$_.no-eq"1"}).ename
John

Powershell rules!

Tags: ,
*