A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: New to XML

  1. #1

    New to XML

    Hi,

    I have an XML file which has got some animal names and I want to fetch all the animal names in a text box.

    Please let me know how should I do that.

    Here is the code that I am using in Flash. Using this code I am getting the name of last animal only.

    Code:
    //First load the XML file through the XML Object
    var OpenXML:XML = new XML(); //I created an instance of the XML Object called "OpenXML"
    OpenXML.ignoreWhite = true;   //ignore the white spaces of the document.
    OpenXML.onLoad = function()   //When load all data, do the following actions.
    {
     var openHowMany:Array = new Array();   //An array to store the nodes of the XML document
      openHowMany = this.firstChild.childNodes;  //This is useful to know how many results do we have.
      
      if(openHowMany.length > 0)   //If we have more than 0 results.
      {
       for(var i:Number =0; i < openHowMany.length; i++){
    		   
        animalName=this.firstChild.childNodes[i].attributes.Name;  //animalName is the name of my textbox
    	
       }
      }
    }
    var date:Date=new Date();
    version=date.valueOf();
    OpenXML.load("open_project.xml");
    I have also attached a text file for XML tags that I am using.
    Attached Files Attached Files
    Smile is a small curve which can solve big problems

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe try this...

    Code:
    if (openHowMany.length>0) {
    	//If we have more than 0 results.
    	animalName = "";
    	for (var i = 0; i < openHowMany.length; i++) {
    		animalName += this.firstChild.childNode[i].attributes.Name +"\n";
    	//animalName is the name of my textbox
    	}
    }

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