使用jQuery $()。find解析带有命名空间的XML [英] Parsing XML with namespaces using jQuery $().find

查看:469
本文介绍了使用jQuery $()。find解析带有命名空间的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取XML文档元素的内容,但该元素的名称中包含冒号。

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?

推荐答案

使用反斜杠,它本身应该被转义,因此JavaScript不会吃它:

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

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

这篇关于使用jQuery $()。find解析带有命名空间的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆