Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing XML with namespaces using jQuery $().find

Tags:

I'm trying to get the contents of a XML document element, but the element has a colon in it's name.

This line works for every element but the ones with a colon in the name:

$(this).find("geo:lat").text(); 

I assume that the colon needs escaping. How do I fix this?

like image 592
titanous Avatar asked Sep 24 '08 17:09

titanous


1 Answers

Use a backslash, which itself should be escaped so JavaScript doesn't eat it:

$(this).find("geo\\:lat").text(); 
like image 70
Adam Bellaire Avatar answered Sep 25 '22 01:09

Adam Bellaire