1
我想查找<issue>
,其中id = 6
。我該怎麼做?我嘗試以下,但它沒有工作:如何查找按屬性值的元素?
<issues>
<issue>
<id>7</id>
<project id="1" name="testProject"/>
<author id="1" name="testAuthor"/>
<subject>subject</subject>
<start_date>2015-08-24</start_date>
</issue>
<issue>
<id>6</id>
<project id="2" name="testProject2"/>
<author id="2" name="testAuthor2"/>
<subject>subject2</subject>
<start_date>2015-08-24</start_date>
</issue>
</issues>
我的XPath表達式企圖是:
doc.xpath("//id[contains(text(), '6']")
和
doc.xpath("//issue[@id=6]")
這很簡單... @ har07非常感謝! –
@yak_ilnur不客氣。不要忘記[接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)答案,因爲它實際上*回答了你的問題 – har07