如何使用xpath表達式解析HTML和XML文檔
2 回答

心有法竹
TA貢獻1866條經驗 獲得超5個贊
sel.xpath() 得到的依舊是一個SelectorList
參看原文檔
xpath(query)
Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened. List elements implement Selector interface too.
query is a string containing the XPATH query to apply.
那么實際上就是去看Selector 相關的函數了。
————————————————
<p>
AA
<sub>1</sub>
<sub>2</sub>
<sub>3</sub>
</p>
<p>
BB
<sub>1</sub>
<sub>2</sub>
<sub>3</sub>
</p>
對于上述例子,其實可以考慮獲取到p之后,對其內容再進行一次查找,即可獲得 1 、2 、3的內容。
- 2 回答
- 0 關注
- 608 瀏覽
添加回答
舉報
0/150
提交
取消