使用JavaScript / Ajax?
我正在尝试从以下位置提取值:
<yweather:astronomy sunrise="6:34 am" sunset="8:38 pm"/>
寻找类似的东西:
var response = transport.responseXML.getElementsByTagName("channel");
sunrise = response[0].getElementsByTagName("yweather:astronomy").item(0).Attributes["sunrise"].Value;
但到目前为止没有任何作用。 :'( 感谢。
答案 0 :(得分:8)
名称空间有getElementsByTagName
的特殊版本:getElementsByTagNameNS
。
例如:
var response = transport.responseXML.getElementsByTagName("channel");
var sunrise = response[0].getElementsByTagNameNS("[Namespace URI]", "astronomy")[0].getAttribute("sunrise");
...其中[Namespace URI]
是yweather
命名空间的URI。
史蒂夫