Problems reading a part of XML using AC3 ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • panos100m
    New Member
    • Aug 2007
    • 23

    Problems reading a part of XML using AC3 ...

    Hi

    i can read everything from my xml file except a part that i can always get teh first items of each category (it will make more sence in a sec)

    So here is my xml

    [HTML]<?xml version="1.0" encoding="UTF-8"?>
    <flashxml>
    <second_page>
    <sp text="ss ptextj"/>
    <ss text="sptext"/>
    <clas text="clas"/>
    </second_page>
    <third_page>
    <ss>
    <category name="categor">
    <item>3333</item>
    <item>H4444</item>
    <item>etc etc etc </item>
    </category>
    <category name="security ">
    <item>SSL</item>
    <item>Hacke</item>
    <item>etc etc etc </item>
    </category>
    </ss>
    <sp>
    <category name="security a">
    <item>SSL lallalala</item>
    <item>Hacker</item>
    <item>etc etc etc </item>
    </category>
    <category name="onlin">
    <item>Hussle free</item>
    <item>Diafore </item>
    <item>etc etc 2 </item>
    </category>
    </sp>
    <classifieds>
    <category name="Best">
    <item>Additem 1</item>
    <item>Additem 2</item>
    <item>Additem 3 </item>
    </category>
    </classifieds>
    </third_page>
    </flashxml>[/HTML]

    I am trying for each category in the xml to get the relevant items ...

    The problem is that if i try to read for e.g the second set of items for the second category of <sp> using a counter it throws a type error

    TypeError: Error #1010: A term is undefined and has no properties.
    at MethodInfo-1()
    at flash.events::E ventDispatcher/flash.events:Ev entDispatcher:: dispatchEventFu nction()
    at flash.events::E ventDispatcher/dispatchEvent()
    at flash.net::URLL oader/flash.net:URLLo ader::onComplet e()

    so the following works


    Code:
    var itemslist:XMLList = xml.third_page.ss.category[0].item;
    (it will always display the first items of the first category for all the categories

    so for instance for sp will always return even for the second category

    <item>SSL lallalala</item>
    <item>Hacker</item>
    <item>etc etc etc </item>



    but when i am using

    Code:
    var itemslist:XMLList = xml.third_page.ss.category[i].item;
    i am getting the type error above TypeError: Error #1010 .. (no idea why)

    Any help will be much appreciated

    complete code ::


    Code:
    pp.buttonMode = true;
    
    pp.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
    pp.addEventListener(MouseEvent.CLICK, onButtonOut);
    
    function onButtonOver(e:MouseEvent):void
    {
     e.currentTarget.gotoAndPlay("a");
     var xmlString:URLRequest = new URLRequest("ev.xml");
    var xmlLoader:URLLoader = new URLLoader(xmlString);
    xmlLoader.addEventListener("complete", init);
    function init(event:Event):void{
      var xDoc:XMLDocument = new XMLDocument();
      xDoc.ignoreWhite = true;
      var animalsXML:XML = XML(xmlLoader.data);
       //var list:XML = XML(xml Loader.data);
     // trace (animalsXML);  //prints the xml
      
      //edooooooooooooooooooooooooooooooooooo
     var  xml = XML(xmlLoader.data);  
     
               trace ("XML File");   
           trace ("===================");   
               trace (xml.second_page.sp.attribute("text"));    
          trace (xml.second_page.ss.attribute("text"));    
          trace (xml.second_page.clas.attribute("text"));    
         
      //edoooooooooooooooooooooooooooooooooooooooooooooooooooo
      
      
     // Third page ss
       var i = 0;
       var categorylist:XMLList = xml.third_page.ss.category;   
      
              for each (var captionElement:XML in categorylist)   
               {   
         i++;
                   trace (captionElement.attribute("name"));  
        //trace (captionElement.item);
        
        var itemslist:XMLList = xml.third_page.ss.category[0].item; 
        
        for each (var captionElement:XML in itemslist)   
               {   
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
        
                 }   
        
        }           
      
      
     // Third page sp
       var i = 0;
       var categorylist:XMLList = xml.third_page.sp.category;   
      
              for each (var captionElement:XML in categorylist)   
               {   
         i++;
                   trace (captionElement.attribute("name"));  
        //trace (captionElement.item);
        
        var itemslist:XMLList = xml.third_page.sp.category[0].item; 
        
        for each (var captionElement:XML in itemslist)   
               {   
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
        
                 }   
        
        
                 }   
        
        
        
        
        
        
     // Third page clas
      var i = 0;
       var categorylist:XMLList = xml.third_page.classifieds.category;   
      
              for each (var captionElement:XML in categorylist)   
               {
    i++;
               trace (i);
         trace (captionElement.attribute("name"));
        //   trace (captionElement.item);
      // trace (valueOf(captionElement.item));
        //var hi= captionElement.attribute("name");
        
       
        
        
     var itemslist:XMLList = xml.third_page.classifieds.category[0].item; 
        
        for each (var captionElement:XML in itemslist)   
               {   
                    trace(captionElement);
      // trace (valueOf(captionElement.item));
        
                 }     
        
        
        
        
        
        
                 }   
        
        
       
        
      
      
      
      for each(var itemData:XML in animalsXML.elements()) {
     //  trace(itemData.elements().attribute("text")); //DOULEUI
    //third page
    //itemData.thirdpage.elements()[0].@patty 
    }
    
      
      xDoc.parseXML(animalsXML.toXMLString());
      
     // trace(xDoc.firstChild.childNodes[0]); //Riverside
      //trace(xDoc.firstChild.childNodes[0].nodeValue);
      
    //trace(xDoc.valueOf(.getElementsByTagName("item")[0].childNodes[0].nodeValue);
    
     
      }
     
    }
    function onButtonOut(e:MouseEvent):void
    {
     e.currentTarget.gotoAndPlay("b");
     pb.gotoAndPlay("a");
    }
Working...