Use AS3 to parse XML node attribute that has a colon


I have the following XML document:

<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling" xml:lang="en"> <head></head> <body> <div xml:lang="it"> <p begin="00:00:00" end="00:00:02" style="violet">first

</div> </body> </tt>

I load the contents into my flash object using AS3 successfully. But how do print/trace the value of the attribute in <div xml:lang="it">? When I try the code:


The compiler complains about the syntax error presented by the colon.


In your xml there is no 'xml' namespace. Probably you missed it. Should be something like this:

<tt xmlns:xml="http://blabla.com" ... xml:lang="en">

Then you need to declare <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Namespace.html" rel="nofollow">Namespace</a> instance for accessing xml attributes, tags for that namespace:

var ns:Namespace = new Namespace("xml","http://blabla.com") ;

Then you can use this code to access attribute:



Perhaps use: .attribute('xml:lang') instead of .@xml:lang

<a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/XML.html#attribute" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/XML.html#attribute</a>()


Use ::.


<a href="http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e6c.html" rel="nofollow">http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e6c.html</a>


  • How to draw multiple vectors with different color?
  • CSS: Android Web App: Color gradient issue
  • Relationship between active and focused states [duplicate]
  • How to vertically and horizontally center a div of unknown height
  • unrecognized selector isPitched called
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • maven jboss-as:start A required class was missing … org/sonaty…/ArtifactResolutionException
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Configure Spring's MappingJacksonHttpMessageConverter
  • Why isn't obj.style.left = “200px”; working in this code?
  • Tell Git to stop prompting me for conflicts when none really exist?
  • AppleScript : find open tab in safari by name and open it
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • saving file generated by TCPDF
  • Loading .coffee files via a view in Rails
  • Create DicomImage from scratch using Dcmtk
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Problem deserializing objects from cache on MyBatis 3/Java
  • Play WS (2.2.1): post/put large request
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Jquery UI tool tip close icon
  • FileReader+canvas image loading problem
  • Insert into database using onclick function
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • jquery mobile loadPage not working
  • align graphs with different xlab
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Return words with double consecutive letters
  • Unanticipated behavior
  • Reading document lines to the user (python)
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • Python/Django TangoWithDjango Models and Databases
  • How to load view controller without button in storyboard?