seems to be that the root element is not treated as a node (or rather that the root element is the same as the model object itself). Using the flex debugger in flex builder you can check what txml actually contains.

try this one instead:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
  
 <mx:Model id="txml">
        <employees>
            <employee>
                <firstname>Aaron</firstname>
            </employee>
            <employee>
                <firstname>DDDDD</firstname>
            </employee>
        </employees>
    </mx:Model>
  
    <mx:Script>
        private function init():void
        {
           lbl.text = txml.employee[0].firstname;
        }
    </mx:Script>
  
   <mx:Label id="lbl" />

</mx:Application>

aaron smith wrote:

look at this example:


:::::

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml " layout="absolute" creationComplete="init()">
   
    <mx:Model id="txml">
        <employees>
            <employee>
                <firstname>Aaron</firstname>
            </employee>
            <employee>
                <firstname>DDDDD</firstname>
            </employee>
        </employees>
    </mx:Model>
   
    <mx:Script>
        private function init():void
        {
            XPLogger.info( txml.employees.employee[0].firstname );
        }
    </mx:Script>
   
</mx:Application>

::::::


This generates a runtine error: "Cannot access a property or method of a null object reference."

Why exactly is this generating a runtime error? I can't figure it out.. even when you try this:: XPLogger.info( txml.employees.employee[0] )

now the other thing is this. when i do an XPLogger.info( txml.employees ) it traces as [object]

any ideas?


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to