title: How to get xml field value using csv column header powershell
body: <p>When I use for loop and then add value $b here in code <strong>({ $_.'field_name' -eq  $b}</strong> then it's giving blank value instead of result.</p>
  <pre><code>$CSVpath = &quot;G:\1.csv&quot;
  $columncount=((Get-Content $CSVpath)[0] -split &quot;,&quot;).count
  write-host $columncount
  $xml= &quot;G:\1.xml&quot;
  [xml] $xmlDoc = Get-Content $xml
  for($i=0; $i -le $columncount;$i++){
  $a = ((Get-Content $CSVpath)[0] -split(','))[$i]
  $b= &quot;'$a'&quot;
  Function xml{
  param($value)
  $xml= &quot;G:\1.xml&quot;
  [xml] $xmlDoc = Get-Content $xml
  $a1= $xmlDoc.enum_types.enum_type.Where({ $_.'field_name' -eq  $b}, 'First').items.item.where({ $_.id -eq 1}).value
  $d = $a1.'#cdata-section'
  write-host  $d
  }
  xml $b
  }
  </code></pre>
  <p>Please help me to resolve issue.
  Please find xml:</p>
  <pre><code>    &lt;enum_types&gt;
      
          &lt;enum_type field_name=&quot;Test1&quot;&gt;
              &lt;items&gt;
                  &lt;item&gt;
                      &lt;id&gt;1&lt;/id&gt;
                      &lt;value&gt;A&lt;/value&gt;
                  &lt;/item&gt;
              &lt;/items&gt;
              &lt;/enum_type&gt;
  &lt;enum_type field_name=&quot;Test2&quot;&gt;
              &lt;items&gt;
                  &lt;item&gt;
                      &lt;id&gt;1&lt;/id&gt;
                      &lt;value&gt;A&lt;/value&gt;
                  &lt;/item&gt;
              &lt;/items&gt;
              &lt;/enum_type&gt;
          &lt;/enum_types&gt;
  </code></pre>
  <p>Please find csv file : <a href="https://i.stack.imgur.com/siXys.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/siXys.png" alt="enter image description here" /></a></p>