title: With powershell from TXT to XML
body: <p>with the following powershell script could I transfer TXT to Powershell.</p>
  <p>Here the powershell Code:</p>
  <pre><code>    $file = 'D:\orders.txt'
  $ausgabeordner = 'D:\Ausgabe'
  
  gc $file | %{
      $cols = $_.split(&quot;;&quot;)
      [xml]$xml = @&quot;
  &lt;?xml version=`&quot;$($cols[0])`&quot; encoding=`&quot;$($cols[1])`&quot;?&gt;
  &lt;PurchaseOrder PurchaseOrderNumber=&quot;$($cols[2])&quot; OrderDate=&quot;$($cols[3])&quot;&gt;
      &lt;Address Type=&quot;$($cols[4])&quot;&gt;
          &lt;Name&gt;$($cols[5])&lt;/Name&gt;
          &lt;Street&gt;$($cols[6])&lt;/Street&gt;
          &lt;City&gt;$($cols[7])&lt;/City&gt;
          &lt;State&gt;$($cols[8])&lt;/State&gt;
          &lt;Zip&gt;$($cols[9])&lt;/Zip&gt;
          &lt;Country&gt;$($cols[10])&lt;/Country&gt;
      &lt;/Address&gt;
      &lt;Items/&gt;
  &lt;/PurchaseOrder&gt;
  &quot;@
      $itemsnode = $xml.SelectSingleNode(&quot;/PurchaseOrder/Items&quot;)
      0..((($cols.Count - 11)/5)-1) | %{
          $index = 11+($_*5)
          $itm = $xml.CreateElement(&quot;Item&quot;)
          $itm.SetAttribute(&quot;PartNumber&quot;,$cols[$index])
  
          $node = $Xml.CreateElement(&quot;ProductName&quot;)
          $node.innerText = $cols[$index+1]
          [void]$itm.AppendChild($node)
          $node = $Xml.CreateElement(&quot;Quantity&quot;)
          $node.innerText = $cols[$index+2]
          [void]$itm.AppendChild($node)
          $node = $Xml.CreateElement(&quot;Price&quot;)
          $node.innerText = $cols[$index+3]
          [void]$itm.AppendChild($node)
          $node = $Xml.CreateElement(&quot;Comment&quot;)
          $node.innerText = $cols[$index+4]
          [void]$itm.AppendChild($node)
          [void]$itemsnode.AppendChild($itm)
      }
      $xml.Save((join-path $ausgabeordner &quot;Order_$($cols[2]).xml&quot;))
  }
  </code></pre>
  <p>This ist the XML File:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;PurchaseOrder PurchaseOrderNumber=&quot;12345&quot; OrderDate=&quot;2020-09-25&quot;&gt;
  &lt;Address Type=&quot;Shipping&quot;&gt;
  &lt;Name&gt;Max Muster&lt;/Name&gt;
  &lt;Street&gt;Beispielstraße 123&lt;/Street&gt;
  &lt;City&gt;Musterstadt&lt;/City&gt;
  &lt;State&gt;Muster-Bundesland&lt;/State&gt;
  &lt;Zip&gt;12345&lt;/Zip&gt;
  &lt;Country&gt;Musterland&lt;/Country&gt;
  &lt;/Address&gt;
  &lt;Items&gt;
  &lt;Item PartNumber=&quot;123456&quot;&gt;
  &lt;ProductName&gt;Beispielartikel&lt;/ProductName&gt;
  &lt;Quantity&gt;1&lt;/Quantity&gt;
  &lt;Price&gt;149.95&lt;/Price&gt;
  &lt;Comment&gt;Beispielkommentar&lt;/Comment&gt;
  &lt;/Item&gt;
  &lt;Item PartNumber=&quot;1234567&quot;&gt;
  &lt;ProductName&gt;Beispielartikel-1&lt;/ProductName&gt;
  &lt;Quantity&gt;5&lt;/Quantity&gt;
  &lt;Price&gt;119.95&lt;/Price&gt;
  &lt;Comment&gt;Beispielkommentar-1&lt;/Comment&gt;
  &lt;/Item&gt;
  &lt;/Items&gt;
  &lt;/PurchaseOrder&gt; 
  </code></pre>
  <p>But now I would like to change the xml file via powershell to the following:
  ( above the )</p>
  <pre><code>    &lt;Item PartNumber=&quot;1234567&quot;&gt;
      &lt;ProductName&gt;Beispielartikel-1&lt;/ProductName&gt;
      &lt;Quantity&gt;5&lt;/Quantity&gt;
      &lt;Price&gt;119.95&lt;/Price&gt;
      &lt;Comment&gt;Beispielkommentar-1&lt;/Comment&gt;
  &lt;Test xsi:nil=&quot;true&quot;/&gt;
      &lt;/Item&gt;
  </code></pre>
  <p>Could someone help me how it works?</p>
  <p>It looks like the colon is causing problems. But I can't say what exactly the error is.</p>