parent / child - NODES - ahhh- HELP!!!
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: parent / child - NODES - ahhh- HELP!!!

  1. #1
    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

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhh...

    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.

  3. #3

    almost

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com