我对dom选择器有疑问。这是我试图解析的xml文件的一部分。
<title>LASTorder "Reindeer"</title>
<enclosure length="23152990" type="application/x-shockwave-flash" url="http://vimeo.com/moogaloop.swf?clip_id=58822081"/>
当我进行查询时
getElementsByTagName('title').childnnodes[0].nodevalue
它返回标题标签的内容。
我应该使用什么查询来获取机箱内的url值?
getElementsByTagName('enclosure').childnnodes[2].nodevalue
这不起作用。
答案 0 :(得分:2)
元素没有任何子节点,只有属性。
element.getAttribute('name_of_attribute');