Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: Convert chlid nodes to var

  1. #1

    Convert chlid nodes to var

    Hi, I tried the last 3 hours to convert child nodes to variables.

    I followed the tutorial on http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm

    I use the following (working) code:
    Code:
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest("language.xml"));
    function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    ParseLanguages(xmlData);
    }
     
    function ParseLanguages(LanguagesInput:XML):void {
    trace("XML Output");
    trace("------------------------");
    var languageList:XMLList = LanguagesInput.Language.(Country == "CtryNo=752&LangNo=46");
    trace(languageList);
    }
    My output is:
    Code:
    <Language lang="Sweden">
      <Country>CtryNo=752&amp;LangNo=46</Country>
      <Search>Sök</Search>
      <Link>Länk till produktsida</Link>
      <CompBat>Kompatibelt med följande batterier</CompBat>
      <CompDev>Kompatibelt med följande apparater</CompDev>
    </Language>
    Now I try to assign variables to each child (Country, Search, Link, etc). But I don't seem to succeed with that.

    I tried different approaches like:

    • var test = languageList.Country
    • var test = e.item.Country

    In my xml file I have 8 languages. I'm grateful for any help I can get :-)

  2. #2
    185
    posts
    Registered User
    Here is a pretty thorough tutorial for you..
    http://www.republicofcode.com/tutorials/flash/as3xml/

  3. #3
    Thanks!!! That was exactly what I needed :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012