无法使用 jquery 获取 xml 属性的值

Not able to get the value of xml attribute using jquery

本文关键字:xml 属性 获取 jquery      更新时间:2023-09-26

我正在尝试使用 jquery 访问 xml 标签的属性值。我尝试访问的 xml 标签属性是:

<yweather:condition code="30" date="Fri, 04 Mar 2016 12:53 pm AKST" temp="11" text="Partly Cloudy"/>

我正在尝试在成功函数中按如下方式访问它:

alert($(xml).find('yweather:condition').attr("temp"));

但它正在提醒"未定义"。无法理解出了什么问题

需要根据 jQuery 选择器文档转义''特殊字符

尝试

alert($(xml).find('yweather'':condition').attr("temp"));