20
Mar
08

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#">
<rdf:Description>
<rdf:value>xxx</rdf:value>
</rdf:Description>
</rdf:RDF>
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#">
<cm:Description>
<rdf:value>xxx</rdf:value>
</cm:Description>
</rdf:RDF>
I nabbed this chunk of code from the Flex Developer’s Guide, section “Handling results as XML with the e4x result format.

4 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! :D

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

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


Leave a Reply