Hi Josh,

Thanks for the lead. I'm new to this but by looking at the Flex
documentation it seems that you would need to hardcode the uri into
QName/namespace? What I mean is that I am trying to get the default
namespace at runtime so that ideally my code would still run in the
case YouTube changed their namespaces;) But unfortunately it doesn't work:

var def:Namespace = new Namespace(xml.namespace());
use namespace def;

...

Could you give the code about QName? Thanks!


--- In flexcoders@yahoogroups.com, "Josh McDonald" <[EMAIL PROTECTED]> wrote:
>
> It should work, but you need to either use a QName (instead of a
String) to
> access nodes. Also, you could probably define an namespace like this
(off
> the top of my head, syntax might be wrong):
> 
> private namespace rootNS = "http://www.w3.org/2005/Atom";;
> 
> using rootNs;
> 
> //... Do your e4x stuff here...
> 
> I'd say use QNames. I know at first it seems kinda annoying to have to
> define a bunch QName constants, but when Youtube decide to change their
> namespaces, or the name of a node, or something like that, you'll be
glad
> you did.
> 
> -Josh
> 
> On Mon, Sep 15, 2008 at 4:50 AM, gwangdesign <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> >
> > I am trying to access the YouTube feed. Like this:
> >
> > "
> >
http://gdata.youtube.com/feeds/api/videos?rq=HurricaneIKE%20&max-results=2
> > "
> >
> > It returns something like this:
> >
> > <feed
> > xmlns='http://www.w3.org/2005/Atom'
> > xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
> > xmlns:gml='http://www.opengis.net/gml'
> > xmlns:georss='http://www.georss.org/georss'
> > xmlns:media='http://search.yahoo.com/mrss/'
> > xmlns:batch='http://schemas.google.com/gdata/batch'
> > xmlns:yt='http://gdata.youtube.com/schemas/2007'
> > xmlns:gd='http://schemas.google.com/g/2005'>
> >        <id/>
> >        <updated/>
> >        <author/>
> >        <generator/>
> >        <openSearch:totalResults>127862056</openSearch:totalResults>
> >        ...
> >        <entry>
> >        ...
> >        </entry>
> > </feed>
> >
> > Everything is fine except that I cannot traverse the returned xml file
> > in e4x syntax, while the old school child(0) works just fine. After
> > hours of digging, I found out that it was the namespace of the top
> > node:"http://www.w3.org/2005/Atom"; that prevents e4x from working. I
> > figured this out by saving a local copy of the xml file and trimming
> > off the aforementioned uri of the namespace, like this:
> >
> > <feed
> > xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
> > xmlns:gml='http://www.opengis.net/gml'
> > xmlns:georss='http://www.georss.org/georss'
> > xmlns:media='http://search.yahoo.com/mrss/'
> > xmlns:batch='http://schemas.google.com/gdata/batch'
> > xmlns:yt='http://gdata.youtube.com/schemas/2007'
> > xmlns:gd='http://schemas.google.com/g/2005>
> > ...
> > </feed>
> >
> > So what I am trying to do now, without any good advice, is trying to
> > set the namespace for the top node to another uri or just null,
> > because that's what's working with a local copy.
> >
> > BTW, I tried both HTTPService and URLLoader/URLRequest and they yield
> > the same results. I tried copy() the xml file without altering the
> > namespaces for the top node and it ONLY worked for a local xml file.
> >
> > Any suggestions?
> >
> >
> > ------------------------------------
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Alternative FAQ location:
> >
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > Links
> >
> >
> >
> >
> 
> 
> -- 
> "Therefore, send not to know For whom the bell tolls. It tolls for
thee."
> 
> http://flex.joshmcdonald.info/
> 
> :: Josh 'G-Funk' McDonald
> :: 0437 221 380 :: [EMAIL PROTECTED]
>


Reply via email to