2012-01-18 75 views

回答

0

試試這個:

//descendant::*[@class='product-details box']/ul/li[span='Sales rank: ']/text() 
+0

這將選擇一個以上的節點 - 要知道唯一的空白文本的節點。 – 2012-01-18 14:22:12

+0

awesome this works:query(「// descendant :: * [@ class ='product-details box']/ul/li [span ='Sales rank:']/text()」) - > item(0) - >的nodeValue; – Abhi 2012-01-19 02:50:22

+0

如果您接受答案,請立即行動起來。 – Jayy 2012-01-19 08:28:25

0

您可以嘗試使用:

//div[@class="product-details"]/ul/li[9] 

雖然未經測試。

+0

的問題是,它並不總是第九元素:) – Abhi 2012-01-18 19:47:30

0

使用

//li[@id='yui_3_4_1_1_1326860702769_9706'] 
    /span[. = 'Sales rank: '] 
     /following-sibling::text()[1] 

這將選擇與字符串值'Sales rank: '任何span元素的先上後下,兄弟文本節點,那就是任何li的孩子元素的id屬性的值爲'yui_3_4_1_1_1326860702769_9706'

+0

謝謝Dimitre。但是「yui_3_4_1_1_1326860702769_9706」是這些部分的動態生成編號,因此無法使用它。 – Abhi 2012-01-18 19:41:04

0

試試這個,如果有任何疑問,請讓我知道

`//li[@id]/*[contains(text(), 'Sales rank')]/following-sibling::node()[1]`