# XML access question

**URL:** <https://forum.kirupa.com/t/xml-access-question/291210>\
**Category:** flash\
**Created:** [June 26, 2009, 9:52am UTC](https://forum.kirupa.com/t/xml-access-question/291210 "2009-06-26T09:52:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dail](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@dail](https://forum.kirupa.com/u/dail)\
**Post date:** [June 26, 2009, 9:52am UTC](https://forum.kirupa.com/t/xml-access-question/291210/1 "2009-06-26T09:52:40Z")

</div>

HI,

I’m just messing around with an XML iterator, and I have a simple mapping method, that given a key, maps said key to xml and returns the relevant xml.

Now, it works if I hard code in the XML node that I want to match the key against, but thats not that flexible. So, I want to also be able to pass in the node to match against, but it seems I am getting defeated, by what I thought would be simple.

heres the method I have below;

```auto

		public function mapIndex(key:String, xmlNode:*):Object {
   // a nice list of my xml, but its no good if I cant compare it against my key
			trace(xmlNode, _collection.elements(xmlNode)==key);
			return _collection.([xmlNode] == key).length() == 0 ? _collection[0] : _collection[_collection.([xmlNode] == key).childIndex()];
     //hard coded below, works fine
    //return _collection.(image == key).length() == 0 ? _collection[0] : _collection[_collection.(image == key).childIndex()];
		}

```

So, what I need to know, is how to get that xmlNode param into the correct datatype for flash to recognise it within an XML child call.

Thanks.
