# Extract complete individual node from a XML file

**URL:** <https://forum.kirupa.com/t/extract-complete-individual-node-from-a-xml-file/299629>\
**Category:** Uncategorized\
**Created:** [November 8, 2009, 3:54pm UTC](https://forum.kirupa.com/t/extract-complete-individual-node-from-a-xml-file/299629 "2009-11-08T15:54:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [November 8, 2009, 3:54pm UTC](https://forum.kirupa.com/t/extract-complete-individual-node-from-a-xml-file/299629/1 "2009-11-08T15:54:32Z")

</div>

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)

```auto
<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.

```auto
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:

```auto
<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:

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

```

Thank you for your consideration,

S
