2013-02-05 181 views
0

我有一個關於dom選擇器的問題。這是我想解析的xml文件的一部分。解析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 

這是行不通的。

回答

2

元素沒有得到任何的子節點,它只有屬性。

element.getAttribute('name_of_attribute');