How can I handle XML namespaces in CSS Selectors or in jQuery?

醉酒当歌 提交于 2019-12-01 05:55:25

CSS allows you to specify namespaces for use with selectors within stylesheets.

However, jQuery doesn't support this since you have no way of declaring the XML namespace in the first place (as jQuery has nothing to do with CSS besides borrowing from its selector syntax), so you have to treat the colon as a literal character instead by escaping it like so:

xml.find("channel > itunes\\:image")

I want to add something wired I just explored: If I try the above code on my rekonq browser (which uses webkit), I cannot find the <itunes:image> tag by searching for xml.find("channel > itunes\\:image").

I have to omit the term itunes: and have to type xml.find("channel > image"). So we have:

xml.find("channel > itunes\\:image") /* Firefox */

xml.find("channel > image") /* Rekonq (maybe also Safari and Chrome?!) */
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!