# XML and Objects

**URL:** <https://forum.kirupa.com/t/xml-and-objects/258048>\
**Category:** flash\
**Created:** [April 20, 2008, 8:57am UTC](https://forum.kirupa.com/t/xml-and-objects/258048 "2008-04-20T08:57:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blinker\_dk](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@blinker\_dk](https://forum.kirupa.com/u/blinker_dk)\
**Post date:** [April 20, 2008, 8:57am UTC](https://forum.kirupa.com/t/xml-and-objects/258048/1 "2008-04-20T08:57:52Z")

</div>

Hello!

As a part of a CMS I want to link certain Objects to each node in some XML that I load.

Basicly here is the setup

```auto
        
        // Step 1
        var clip:MovieClip = new MovieClip();
        clip.name = "My Clip";
        trace("Name:" + clip.name); // out: My Clip

        // Step 2
        var myXml:XML = <node id='1'><node id='2' /><node id='3'/></node>;
        trace("Node id:" + myXml.node[0].@id); // out: 2

        // Step 3
        myXml.node[0].obj = clip;
        trace("Object:" + myXml.node[0].obj);

        // Step 4
        var obj = myXml.node[0].obj;
        trace("Name:" + myXml.node[0].obj.name); // out nothing

        trace("Type of:" + typeof obj); // out: xml
        trace(myXml.toXMLString());

```

So _clip_ is casted to a string and inserted as an attribute in myXml, -and the reference to _clip_ is lost.

Is there any way to attach an Object reference to a XML node, in a way that makes it possible to retrieve the object back from the XML instance?

Best regards

Martin
