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:
_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.