Hi,
Use "default xml namespace" directive to solve this problem. Sorry, it is not documented in current livedocs for Flex 2 alpha…We are working many things, so hopefully you would see it updated soon...
Solution:
var nsDefault:Namespace = new Namespace("http://example.com/");
var res:XML = <items xmlns="http://example.com/">
<item>apple</item><item>orange</item>
</items>;
default xml namespace = nsDefault; //or default xml namespace = "http://example.com/";
trace(res.item[0]);
Another way of adding namespace to all XML objects
var nsDefault:Namespace = new Namespace("http://example.com/");
default xml namespace = nsDefault;
var res:XML = <items><item>apple</item><item>orange</item></items>;
trace(res.namespace()); //traces -> http://example.com/
trace(res.item[0]);
Note: You know undocumented are subject to change. But I wanted to let you know that there is something which solves this issue.
What "default xml namespace" does?
The default xml namespace directive sets the default namespace to use for XML objects.
Without setting default xml namespace, the default namespace is the unnamed namespace (with the URI set to an empty string). The scope of a default xml namespace declaration is within a function block, like the scope of a variable:.
Hope that helps.
-abdul
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yokota Satoshi
Sent: Saturday, December 03, 2005 2:51 PM
To: [email protected]
Subject: [flexcoders] Parsing XML with namespaces in E4X (Flex2)
Hi,
Is there a way in which I could parse XML with namespaces in E4X?
following code, I can see the value without namespace.
var res:XML = <items><item>apple</item><item>orange</item></items>;
trace(res.item[0]);
but, following code, I could'nt.
var res:XML = <items xmlns="http://example.com/">
<item>apple</item><item>orange</item>
</items>;
trace(res.item[0]);
Thanks,
Yokota Satoshi
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

