Getting Around Unknown Namepsaces in Flex/AS3

In my last post I presented a RegEx solution to remove a pesky namespace from an XML response payload; another possible solution is to use the * notation to specify any namespace like the following:
Any namespace
The following example shows how to get an element or attribute value when any namespace is specified on the element or attribute:
var attributes:XMLList = XML(event.result).*::Description.*::value;
The previous code returns xxx for either one of the following XML documents:
XML document one:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
XML document two:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cm="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
I nabbed this chunk of code from the Flex Developer’s Guide, section “Handling results as XML with the e4x result format.

7 Responses to “Getting Around Unknown Namepsaces in Flex/AS3”

  1. 1 Pier
    April 21, 2009 at 4:39 am

    You saved my life… thank you so much!!!

  2. 2 Pedro
    May 10, 2009 at 6:56 am

    I officially love you man!!! Thanks! 😀

  3. 3 drb
    August 14, 2009 at 8:42 am

    thank you!!!!!!!!!!!

  4. September 2, 2010 at 12:31 pm

    But this would not work for default name space…

  5. 5 strudel
    January 24, 2011 at 4:29 am

    What if the tag’s name is a reserved word e.g. ‘const’?

  6. December 16, 2013 at 12:13 pm

    Hi there to every body, it’s my first pay a visit of this blog;
    this blog consists of remarkable and in fact fine
    material designed for visitors.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: