title: Reverse foreach XML nodes in PowerShell
body: <p>I'm adding related elements (Parent-Child) through an XML file using the following:</p>
  
  <pre><code>[xml]$fileXml = Get-Content 'c:\example.xml'
  
  $fileXml.Elements | % {
    MyAdd-Function $_
  }
  </code></pre>
  
  <p>When deleting these elements, how do I make sure it iterates in the reverse order? I've tried this and it doesn't work:</p>
  
  <pre><code>[xml]$fileXml = Get-Content 'c:\example.xml'
  
  [Array]::Reverse($fileXml.Elements) | % {
    MyRemove-Function $_
  }
  </code></pre>
  
  <p>I'm thinking about turning <code>$fileXml.Elements</code> into an actual array and then reversing, but I was wondering if there's an easier way.</p>