Dang I'm struggling with some work code that I really ought not be thinking about on a Friday night...
How do I access xml tags in other namespaces using jquery1? If I have some xml like:
<xml>
<things>
<thing>hey</thing>
<thing>yeah</thing>
<thing>woo</thing>
</things>
</xml>
I can easily get any of the elements with something like
$('thing')
but how do I get them if the elements are namespaced, like
<xml>
<things>
<stuff:thing>hey</thing>
<stuff:thing>yeah</thing>
<stuff:thing>woo</thing>
</things>
</xml>
I'm simplifying a bit there, but I can't find any info online about how to get this out again; I can't access my elements with
$('stuff:thing')
because that means a stuff tag of type thing...
What am I missing? Do you know what I'm on about? Do you care?
jquery1 is a brilliant javascript library that I use for everything at work (though I haven't really brought this site up to date with much of it), but I'm struggling to use it to process some gecoded rss like the geo:lat and geo:long in here...
I could really do with knowing this for a fairly funky work project, but equally I could do with not thinking about this on a Friday night...
UPDATE: Just ignore the namespace and get it like this:
$('lat, long', xml ).each( function () {
$('#debug').append( '<h2>' + this.nodeName + '=' + $(this).text() + '</h2>' );
} );
javascript: Programming language of the web, mostly how I make my living.
💬 RE: xml namespaces in jquery - 10456
⬅️ London based band I think, sounded like the Libertines :: RE: Starbucks - bouverie place folkestone - 10451 ➡️
Paul Clarkeʼs blog - I live in Hythe near Folkestone. Wed to Clare and dad to 2, I'm a full stack web engineer, + I do js / nodejs, some ruby, python, php etc. I like pubbing, parkrun, eating, home-automation + other diy jiggery-pokery, history, genealogy, Television, squirrels, pirates, lego, + TIME TRAVEL.