# Using nodeName to get Node position

**URL:** <https://forum.kirupa.com/t/using-nodename-to-get-node-position/113142>\
**Category:** Uncategorized\
**Created:** [June 15, 2004, 1:49pm UTC](https://forum.kirupa.com/t/using-nodename-to-get-node-position/113142 "2004-06-15T13:49:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xMetal](https://avatars.discourse-cdn.com/v4/letter/x/c6cbf5/32.png) [@xMetal](https://forum.kirupa.com/u/xMetal)\
**Post date:** [June 15, 2004, 1:49pm UTC](https://forum.kirupa.com/t/using-nodename-to-get-node-position/113142/1 "2004-06-15T13:49:10Z")

</div>

Hello all, perhaps some of you XML wizards can help me.

I have a rather large XML file (though it’s pretty simple in it’s structure). My flash program is using most, but not all of the data in this file, and I am currently setting a variety of flash variables by looking at specific node numbers (i.e. firstChild.childNodes[4].attributes…). This all works fine.

However, this XML does have the big potential of changing or being added to, and what I want to do it read through the XML, look at the nodeNames and return the nodes position. This way, I can set some basic variables to equal the node positions and not have to hardcode everything.

I currently have a simple loop that is grabbing the nodenames and storing them in an array. What I can’t figure out how to do is use this to get node position, and then set a basic “name = nodepositionX”. Then I can use “firstChild.childNodes[name].attributes…” I don’t think this is terribly complicated, but I’m a designer learning all this programming stuff on the fly here. 🙂

This loop works great:

```auto
_root.xmlNodeNames = new Array();
	for (var x=0; x<expertXML.firstChild.childNodes.length; x++) {
		_root.xmlNodeNames[x] = expertXML.firstChild.childNodes[x].nodeName;
	}

```

and get’s me (for example):

Variable \_level0.xmlNodeNames = [object #3, class ‘Array’] [  
0:“physician”,  
1:“machine”,  
2:“calfactor”,  
3:“sponsor”,  
…etc  
]

Thanks for any help or suggestions! Kirupa rocks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 4:35pm UTC](https://forum.kirupa.com/t/using-nodename-to-get-node-position/113142/2 "2004-06-15T16:35:06Z")

</div>

well, there was actually a turotial that did exactly this, which combined with my previous array works great.

Kirupa saves the day yet again…
