E4X and namespaces
Recently I struggled with trying to figure out why I could not traverse loaded XML data using E4X. In one case it was a RSS feed and in another it was Timed Text data. What these data sets have in common is that they declare name spaces. Consider this xml data:
XML:
-
<tt aaa:lang="en" xmlns="http://www.w3.org/2006/04/ttaf1" xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling" xmlns:aaa="http://www.w3.org/XML/1998/namespace">
-
<head>
-
<styling>
-
<style id="1" tts:textAlign="right"/>
-
<style id="2" tts:color="transparent"/>
-
<style id="3" style="2" tts:backgroundColor="white"/>
-
<style id="4" style="2 3" tts:fontSize="20"/>
-
</styling>
-
</head>
-
<body>
-
<div aaa:lang="en">
-
<p begin="00:00:00.25" dur="00:00:03.25">Dreamweaver users now have access to Flash video. Didn't have it before.</p>
-
<p begin="00:00:04.20" dur="00:00:03.07">And if you were to talk to a Dreamweaver user about three or four years ago</p>
-
</div>
-
</body>
-
</tt>
I see that it declares a couple namespaces but I thought since the "p" nodes do not. This ...
Actionscript:
-
trace(timedTextXML..p);
yields nothing. Yet this ...
Actionscript:
-
if (timedTextXML.namespace("") != undefined){
-
default xml namespace = timedTextXML.namespace("");
-
}
-
trace(timedTextXML..p);
works fine.
Categories: Flash development, Flex development

Finally! A work around to this very frustrating problem. Thanks for posting this. Does the line:
default xml namespace = timedTextXML.namespace("");
...basically remove the name space from the node?
Thanks again,
Darren