PDA

Click to See Complete Forum and Search --> : parent / child - NODES - ahhh- HELP!!!



PaulSpitzer
07-12-2001, 12:20 PM
Why?? If my XML document looks like (just an example)...

< parent name="name" >
< child name="child" >
< /parent >

and my flash script looks like....

parentXML = new XML();
parentXML.onLoad = loaded;
parentXML.load("document.xml");

function loaded() {

parentNameX = parentXML.firstChild;
parentName = parentNameX.attributes.name;
}

stop ();

The the name attribute of the parent node is successfully loaded into the variable parentName. But if my XML document looks like...

< ?xml version="1.0" encoding="utf-8" ? >
< parent name="name" >
< child name="child" >
< /parent >

the attribute isn't loaded into the variable? And how do I load the child attributes into variables? I can't seem to get this. Any help would be much appreciated!

thx,

Paul

VAYKENT
07-12-2001, 01:57 PM
Whitespace - whitespace - whitespace

When you add (I think it's called...) XML type declaration, you add whitespace. That whitespace is treated like a text node.

Try:

parentNameX = parentXML.childNodes[1];

and see if that works.

PaulSpitzer
07-12-2001, 02:14 PM
that didn't work but... i used [2] and it did...

parentXML = new XML();

parentXML.onLoad = loaded;
parentXML.load("PaulSpitzer.xml");

function loaded() {

parentNameX = parentXML.childNodes[2];
parentName = parentNameX.attributes.name;

}

stop ();

my xml doc looks like

< ?xml version="1.0" encoding="utf-8" ?>
< parent name="parent">
< child name="child"/>
< /parent>

This is good, I'm getting close! :) thanks. Now I need to figure out how to get the damn < child name="child"> into a variable. Any help with that?