A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Is this valid XML? How can a refer to this CHILD?

  1. #1
    Member
    Join Date
    Apr 2003
    Posts
    40

    Is this valid XML? How can a refer to this CHILD?

    Somebody told me in the Flash forum I can't do this because its is not valid XML. Is it?


    After going through a number of to me partiallt useful tutorials a was able to access the text 'Noth America", "Europe", etc in the attached XML document.


    text=document.firstchild.childNodes[0].firstChild.nodeValue;

    ---result -->text="North America"


    However, I HAVE no clue how to retrieve/refer to the second level 'United States''Canada''France' etc. What is the node sintaxis??

    Can anybody help???

    ---------------------------------------------------------------
    DOCUMENT
    ------------------------------------------------------------------

    PHP Code:
    <?xml version="1.0"?>
    <NEWS>

    <CONTINENT> North America
    <COUNTRY>United States</COUNTRY> 

    <COUNTRY>Canada</COUNTRY> 

    </CONTINENT>


    <CONTINENT> Europe
    <COUNTRY>Great Britain</COUNTRY> 

    <COUNTRY>France</COUNTRY> 

    <COUNTRY>Italy</COUNTRY> 
    </CONTINENT>


    <CONTINENT> Asia
    <COUNTRY>Japan</COUNTRY> 

    <COUNTRY>China</COUNTRY> 

    <COUNTRY>India</COUNTRY> 
    </CONTINENT>



    </NEWS>
    </XML>
    Last edited by tupps; 11-18-2003 at 08:22 PM.

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Just a quick to say I added [ PHP] tags around your XML to make it show it up
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    The only thing that is not valid is the trailing XML tag.

    To refer to other tags within the contintent node you would use:

    text=document.firstchild.childNodes[0].childNodes[1].nodeValue;

    firstChild and childNodes[0] are equivalent.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

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