Determining the version of an HTML-based AIR Application

Earlier today a subscriber on the AIR with HTML and JS listserv asked about how one could get the current version of an AIR application from within the application itself. AIR stores the version number in the application.xml file. This is a free-form value that can be anything (number, string, etc.) A quick Google search turned out this perfect tip: Quick Tip: Display Application Version in your AIR App This worked, but I wanted to mock up a quick HTML version. Unfortunately dealing with XML in JavaScript kind of makes me want to throw up a little. I think ColdFusion has got me spoiled. But once I figured out the syntax (thank you again W3 Schools) I was able to whip up the following demo.

<!– Credit goes to Joseph Labrecque: –> <html> <head> <title>New Adobe AIR Project</title> <script type=”text/javascript” src=”lib/air/AIRAliases.js”></script> <script> function init() { var appdesc = air.NativeApplication.nativeApplication.applicationDescriptor; parser=new DOMParser(); xmlDoc=parser.parseFromString(appdesc,”text/xml”); version = xmlDoc.getElementsByTagName(“version”)[0]; air.trace(version.textContent); document.getElementById(“version”).innerText = version.textContent; } </script> </head> <body onload=”init()”>


Hello, you are running version &lt;span id="version"&gt;&lt;/span&gt; of the application.

&lt;/body&gt; &lt;/html&gt; </code>

The application simply loads up the XML via the NativeApplication object. This is a string, and while we could parse it using regex, I went ahead and did it the “XML” way and converted it to a proper object. Once done it is pretty trivial to get the version. (Again, once you remind yourself how XML stuff is manipulated in JavaScript.) When the application loads, whatever you have in your application.xml for version will show up in the span.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA