A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple: Number of nodes in an XML file?

  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    400

    Simple: Number of nodes in an XML file?

    I'm migrating to using AS3 for my XML and am missing something basic. How do I find the length of my XML document, the number of total nodes? Clearly I need some sleep.

    For example...

    PHP Code:
    var myXML:XML = new XML();
    var 
    XML_URL:String "http://www.example.com/Sample3.xml";
    var 
    myXMLURL:URLRequest = new URLRequest(XML_URL);
    var 
    myLoader:URLLoader = new URLLoader(myXMLURL);
    myLoader.addEventListener("complete"xmlLoaded);

    function 
    xmlLoaded(event:Event):void
    {
        
    myXML XML(myLoader.data);
        
    trace("Data loaded.");

        
    //How do I find the length of myXML?


  2. #2
    Member
    Join Date
    Dec 2002
    Location
    Baku, Azerbaijan
    Posts
    39
    Hi,
    if your xml is like
    Code:
    <data>
    <people>
    <person>Steve</person>
    <person>John</person>
    </people>
    </data>
    then, as far as I remember, you can get the number of <person>s by
    Code:
    myXML = XML(myLoader.data); 
    trace(myXML.people.person.length());//it must trace 2
    I hope, I'm not wrong. At least, you can try this.

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