Get corresponding XML node after selecting?

Hi there,

I am little bit stuck here. I got the following:

1 xml -file, like


<?xml version="1.0" encoding="UTF-8"?>
<items>
  <item>Wyona Ryder</item>
  <item>Uma Thurman</item>
  <item>Tom Cruise</item>
<items>

2 i have succesfull parse the xml file in flash and got them in a pull-down menu.
3 a user can select a name.

My problem: I can trace the chosen name, but i want the corresponding XML node as a var?
That’s if the user selects Uma Thurman the corresponding XML node is 1, so how do i accomplish this?

I am trying to make a ‘getSelectXMLnode’ function, the parse function works properly


//parse xml file
function parseCelebs () {
if (_root.xmlDocument.loaded) {
for (var i = 0; i < _root.xmlDocument.childNodes.length; i++) {
if (_root.xmlDocument.childNodes*.nodeName == 'items') {
// _root.Celebs = this.childNodes*;
var cookieNodes = _root.xmlDocument.childNodes*.childNodes;
for (var j = 0; j < cookieNodes.length; j++) {
	if (cookieNodes[j].nodeName == 'item') {
	_root.Celebs[_root.Celebs.length] = cookieNodes[j].firstChild.nodeValue;
	_root.vips = cookieNodes[j].firstChild.nodeValue;
	//check if all celebs					//trace (_root.vips);
					}
				}
				break;
			}
		}
		// trace (_root.Celebs.length);
		// we need # of celebs for the pull-down 
		noCelebs = _root.Celebs.length;
		_root.xmlDocument = null;
	}
}


function getSelectXMLnode () {
//for debug we use static value of 3 and tom cruise
for (var k = 0; k < 3; k++) {
 if (cookieNode[k].firstChild.nodeValue == 'tom cruise') {
	trace (k);
		}
	}


Thnks in advanced.

Hmm

I trigger the function by a button. I want the corresponding XML- node-array-number to be send as a variable. So in my function below it would be ‘k’.

This is what i have so far.


function getSelectCeleb () {
if (_root.xmlDocument.loaded) {
for (var k = 0; k < 3; k++) {
var cookieNodes = _root.xmlDocument.childNodes*.childNodes;
if (_root.XMLDocument.cookieNodes[k].firstChild.nodeValue == 'tom cruise') {	trace (k);
}		}
} else {
trace ("Hum doesn't work");
}
}

I get the Hum doesn’t work, so somehow i can’t get to the XMLDocument.

Any suggestions,

This function just execute the else-statement not the if


function getSelectCeleb () {
	for (var j = 0; j < _root.xmlDocument.childNodes[0].childNodes.length; j++) {
		var cookieNodes = _root.xmlDocument.childNodes[0].childNodes;
		if (cookieNodes[j].firstChild.nodeValue == "Tom Cruise") {
			trace ("Array" + j + " = " + cookieNodes[j].firstChild.nodeValue);
		} else {
			trace ("Hum doesn't work");
			trace ("Help" + j + " = " + cookieNodes[j].firstChild.nodeValue);
		}
	}
}


Anyone??