Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:55:39+00:00 2026-06-15T22:55:39+00:00

The class example: package { import flash.events.*; import flash.net.*; public class XmlLoader extends EventDispatcher{

  • 0

The class example:

package {

    import flash.events.*;
    import flash.net.*;

    public class XmlLoader extends EventDispatcher{

        private var _xmlList:XMLList;

        public function XmlLoader(xmlPath:String){
            var xmlUrlRequest:URLRequest = new URLRequest(xmlPath);
            var xmlUrlLoader:URLLoader =  new URLLoader(xmlUrlRequest);
            xmlUrlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
        }

        private function xmlLoaded(e:Event):void{
            e.currentTarget.removeEventListener(Event.COMPLETE, xmlLoaded);
            var xml:XML = new XML(e.currentTarget.data);
            this._xmlList = xml.*;
            dispatchEvent(new Event(Event.COMPLETE));
        }

        public function getXmlList():XMLList{
            return this._xmlList;
        }

    }
}

An example of the class use would be:

var menuXmlList:XmlLoader = new XmlLoader("pt/menu.xml");
menuXmlList.addEventListener(Event.COMPLETE, printList);

function printList(e:Event):void{
    trace(e.currentTarget.getXmlList());
}

This will print out the content of the xml file.
How can I access the nodes of the xmlList outside the class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:55:41+00:00Added an answer on June 15, 2026 at 10:55 pm

    I would modify a little the loader
    public class XmlLoader extends EventDispatcher{

            private var _xml:XML;
    
            public function XmlLoader(xmlPath:String){
                var xmlUrlRequest:URLRequest = new URLRequest(xmlPath);
                var xmlUrlLoader:URLLoader =  new URLLoader(xmlUrlRequest);
                xmlUrlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
            }
    
            private function xmlLoaded(e:Event):void{
                e.currentTarget.removeEventListener(Event.COMPLETE, xmlLoaded);
                _xml = new XML(e.currentTarget.data);
                dispatchEvent(new Event(Event.COMPLETE));
            }
    
            public function getXml():XML{
                return this._xml;
            }
    
        }
    }
    

    I will then access the nodes like this.

    var menuXmlList:XmlLoader = new XmlLoader("pt/menu.xml");
    menuXmlList.addEventListener(Event.COMPLETE, printList);
    
    function printList(e:Event):void{
        var myXML:XML = (e.currentTarget.getXml());
    
        var children:XMLList = myXML.children();
        var child:XML;
    
        for each(child in children)
        {
             trace("Node name: "+child.name()+" -- value: "+String(node));
        }
    
        // for and xml like
        // <root>
        //     <node1>
        //           <subnode>abc</subnode>
        //           <subnode>def</subnode>
        //           <subnode>ghi</subnode>
        //     </node1>
        //     <node2>
        //           <subnode>123</subnode>
        //           <subnode>456</subnode>
        //           <subnode>789</subnode>
        //     </node2>
        // </root>
        //
        // to access all subnodes inside node 2 use
        //
        // var list:XMLList = xml.node2.subnode;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package { import com.greensock.TweenLite; import flash.display.Sprite; public class TweenTest extends Sprite { private var
Let's Say I Have This Class: package{ import flash.display.Sprite; public class Main extends Sprite{
If I have the following class: package com.example; import org.springframework.beans.factory.annotation.Required; public class Customer {
This confuses me. The following compiles fine under Eclipse. package com.example.gotchas; public class GenericHelper1
In the following class: public class Example<T> where T : IComparable { private T
Given: class example { public: std::vector<std::vector<int>> a; int b; } func() { example e;
struct GPattern() { int gid; .... } class Example() { public: void run(string _filename,
I would like to modify an object private variable class Example(): __myTest1 = 1
Here is an example of the code I'm working on: package button { import
I came across the following memory leak example package com.justinschultz.android; import android.app.Activity; import android.app.AlertDialog;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.