title: Mule iterate over xpath result
body: <p>I've set the following xml as <code>payload</code> in order to iterate over every product using <code>splitter</code> component.</p>
  
  <pre><code>&lt;root&gt;
      &lt;product&gt;
          &lt;id&gt;1&lt;/id&gt;
          &lt;name&gt;apple&lt;/name&gt;
      &lt;/product&gt;
      &lt;product&gt;
          &lt;id&gt;2&lt;/id&gt;
          &lt;name&gt;orange&lt;/name&gt;
      &lt;/product&gt;
  &lt;/root&gt;
  
  &lt;splitter expression="#[xpath('//product')]" /&gt;
  </code></pre>
  
  <p>The <code>splitter</code> component returns an object of type <code>org.dom4j.tree.DefaultElement</code> on which I call the method <code>asXML()</code> to get single product's xml.</p>
  
  <p>First iteration</p>
  
  <pre><code>&lt;product&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;name&gt;apple&lt;/name&gt;
  &lt;/product&gt;
  </code></pre>
  
  <p>Second iteration</p>
  
  <pre><code>&lt;product&gt;
      &lt;id&gt;2&lt;/id&gt;
      &lt;name&gt;orange&lt;/name&gt;
  &lt;/product&gt;
  </code></pre>
  
  <hr>
  
  <p>I need to replace <code>splitter</code> with <code>foreach</code> component, but I'm having some troubles.</p>
  
  <pre><code>&lt;foreach collection="#[xpath('//product')]"&gt;
      ...
  &lt;/foreach&gt;
  </code></pre>
  
  <p>The <code>foreach</code> component returns an object of type <code>org.apache.xerces.dom.ElementNSImpl</code> which hasn't the method <code>asXML()</code>.
  Any idea how I can get products'xml as <code>String</code> as explained in the first example? </p>
  
  <p>Thanks in advice!</p>