Extract complete individual node from a XML file

Hi,

I want to extract each individual node from and XML file. I want to preserve the node data AND the attribute name and the attribute data. In short create a new XML that is a copy of the complete node.

I am sure this is pretty simple but whilst I keep getting close I seem unable to get it to work!

Here is an example to illustrate:

If my XML file is like this (just an example)

<X>
     <O A='1' Z='22' Q='13'>DataX</O>
     <O A='54' B='25' C='16'>DataY</O>
     <O G='47' F='38' C='19'>DataZ</O>
</X>

…and I load it and so on to the point where I would have this.

xd=new XML(e.target.data);
trace(xd)// traces out the XML file as above

What I want is to have something that would produce a trace like this:

<O A='1' Z='22' Q='13'>DataX</O>
-----
<O A='54' B='25' C='16'>DataY</O>
-----
<O G='47' F='38' C='19'>DataZ</O>
-----

from somthing like this:

for each (var x:XML in xd.O)
{
     trace(x) // this is not it though 
     trace('------');
}

Thank you for your consideration,

S