Hi Gordon, I agree that its good to know the :: syntax, but it usually seems extremely inconvenient to me. The fact that you cannot use it in conjunction with the .. syntax makes it pretty painful to use to retrieve anything that is even slightly deeply nested.
Ben --- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > This may work for the example at hand. But rather than relying on "use > namespace" or "default xml namespace" you should also understand how to > use namespaces when there are more than one of them in your XML, because > this is the more general case > > > > You can declare variables that represent namespaces > > > > var nsFoo:Namespace = new Namespace("http://foo"); > > var nsBar:Namespace = new Namespace("http://baf"); > > > > and then use these with the :: operator to make expressions like > nsFoo::foo which means "the <foo> tag in the namespace "http://foo". > > > > You can then build up larger E4X expresions which pick out tags or > attributes that live in a variety of namespaces, as in > > > > xml.nsFoo::foo.nsBar::bar > > > > Using the :: operator also has the virtues of explicitness and > as-narrow-as-possible scoping. > > > > - Gordon > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of cluebcke > Sent: Wednesday, November 22, 2006 9:49 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: e4x/default namespaces question > > > > Thank you Ben. What's described below didn't work for a default > namesapce; mawilliford provided the missing link, the "default xml > namespace" directive. > > Please rest assured that I would never post a question here without > having searched thoroughly through the archives, google, livedocs, > etc. Now that I know the correct syntax, it's easy to find a number of > messages that provide the answer. But I was unable to sort the wheat > from the chaff (there's a /lot/ of discussion on namespaces, and only > a little of on default xml namespaces), and I appreciate the help > offered (I did read the thread Gordon mentioned as well, but it didn't > seem to address my specific issue--maybe I just missed it). > > Thanks again, > Chris > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > , "ben.clinkinbeard" > <ben.clinkinbeard@> wrote: > > > > As Gordon mentioned, there should be plenty of discussion on this > > topic in the archives, but I can provide some assistance here as well. > > (Just promise to always do a search first from now on :)) > > > > The easiest approach is this: > > > > namespace foo = "myDefaultNamespace"; > > use namespace foo; > > > > You will then be able to use e4x expressions as if there were no > > namespace present. The use directive stays active in the scope it is > > defined, so it can be done on a per method basis or class-wide. > > > > HTH, > > Ben > > > > > > > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> , "cluebcke" <cluebcke@> wrote: > > > > > > I was struggling with being able to use a perfectly fine XMLList > > > (returned from an HTTPService, resultFormat="e4x") as a dataprovider > > > for a datagrid. What I finally figured out was that I wasn't able to > > > properly handle a default (i.e. not prefixed) namespace. My top > level > > > element was something like this: > > > > > > <listOfThings xmlns="myNamespace"> > > > <thing> > > > <thing> > > > </listOfThings> > > > > > > No matter how I tried (including using the .* notation which should > > > match any namespace) I couldn't programmatically access the data. I > > > found two ways around this. > > > > > > 1. Remove the namespace: > > > > > > <listOfThings> ...etc > > > > > > 2. Assign the namespace a prefix, use it for the top-level element, > > > and provide it when accessing the XMLList via e4x: > > > > > > <myco:listOfThings xmlns:myco="myNamespace"> > > > > > > So, is there some extra magic for accessing a top-level default > > > namespace that I'm just too dense to get? Or is this use of default > > > namespaces not supported/allowed? > > > > > > Thanks, > > > Chris > > > > > >