The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


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