2015-12-02 76 views
0

我有幾個條目的XML如下(與其他標籤一起爲好)XPath來獲得兩個條目

<entry> 
     <id> 
      https://spreadsheets.google.com/feeds/cells/14sCud5RqFt7O44Ol_GnTBgwFbZSnWAW-dJ833ryfWY8/1/private/full/R4C3 
     </id> 
     <updated>2015-12-02T05:49:20.867Z</updated> 
    </entry> 
<entry> 
     <id>https://spreadsheets.google.com/feeds/cells/14sCud5RqFt7O44Ol_GnTBgwFbZSnWAW-dJ833ryfWY8/1/private/full/R3C2 
     </id> 
     <updated>2015-12-02T05:49:20.867Z</updated> 
</entry> 

我想獲得使用XPath表達式前兩個<entry>標籤。我可以使用xpath來做到這一點嗎?如果是這樣的話。

+0

你能粘貼一個更長的例子與幾個''元素?他們是兄弟姐妹嗎(在樹上的同一級別)?或者前2個有不同的父元素? –

+0

入門元素是在同一級別 - 他們是兄弟 –

+0

好吧,所以@ Dmytro的答案將工作 –

回答

3

像這樣。

//entry[position()<3]