Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

88 | Chapter 4: AIR Mini-Cookbook


<script>
var file = null;
var xml = null;

function doLoad( )
{
file = air.File.applicationResourceDirectory;
file = file.resolve( "rolodex.xml" );

xml = new XMLHttpRequest( );

xml.onreadystatechange = function( )
{
var elem = null;
var first = null;
var last = null;
var rolodex = null;

if( xml.readyState == 4 )
{
rolodex = xml.responseXML.documentElement.
getElementsByTagName( "contact" );

for( var c = 0; c < rolodex.length; c++ )
{
first = rolodex[c].getElementsByTagName(
"first" )[0].textContent;
last = rolodex[c].getElementsByTagName(
"last" )[0].textContent;

elem = document.createElement( "div" );
elem.innerText = first + " " + last;
document.body.appendChild( elem );
}
}
}

xml.open( "GET", file.url, true );
xml.send( null );
}
</script>

</head>
<body onload="doLoad( )">

</body>
</html>
Free download pdf