topical media & game development
professional-flex-code-17-XMLUsers.mx
professional-flex-code-17-XMLUsers.mx
(swf
)
[ flash
]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()">
// static text/xml file
<mx:XML id="usersXML" source="users.xml" />
<mx:Script>
<![CDATA[
private function init():void
{
// List Users using the dot operator
var userList:XMLList = usersXML.user;
trace( userList.toXMLString() );
// List Users using the XML children() method, same result
userList = usersXML.children();
trace( userList.toXMLString() );
// List Phone Numbers using the descendent operator
var phoneList:XMLList = usersXML..phone;
trace( phoneList.toXMLString() );
// List Phone Numbers using the XML descendants() method, same result
phoneList = usersXML.descendants( "phone" );
trace( phoneList.toXMLString() );
// List Users in IT using the attribute operator
var phoneList:XMLList = usersXML.user.(@department == "IT" );
trace( phoneList.toXMLString() );
// List Users in IT using the XML attribute() method, same result
phoneList = usersXML.user.(attribute( "department" ) == "IT" );
trace( phoneList.toXMLString() );
}
]]>
</mx:Script>
</mx:Application>
(C) A. Eliëns
2/9/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.