Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Load And Parse XML in Action script

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 585
    Comment on it

    It is very easy to load and parse XML in Action Script 3.0

    Suppose we have xml like this -

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <images>
    <image>
        <url>"first.jpg"</url>
    </image>
    <image>
        <url>"Second.jpg"</url>
    </image>
    <image>
        <url>"Third.jpg"</url>
    </image><images>
    

    So for load and parse we have few lines code below :

    public function loadXML():void
    {
                  //path of xml file
              var url:String = "...//images.xml"
              var imagesLoader:URLLoader =  new URLLoader()
              try
               {
    
                  var imagesURL:URLRequest=new URLRequest(url)
                  imagesLoader.load(imagesURL)
                  imagesLoader.addEventListener(Event.COMPLETE,loadImages)
                  imagesLoader.addEventListener(IOErrorEvent.IOERROR,ioError)
               }
              catch(e)
               {
    
               }
        }
    
        public function ioError(evt:IOErrorEvent):void
        {
               trace("ERROR")
        }
    
    
        private function loadImages(evt:Event):void
        {   
    
            var  itemsXML:XML= new XML(evt.target.data)
            for each (var image:XML in xmlData.image)
           {
                    trace("get images url ",image.url)  
           }
        }
    

    May be it would help !

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: