python - How to select two or more elements from the same node with Xpath? -
i select 2 elements same node. here code:
<div >   <span >first element select:</span>   <span ></span>   <strong >second element select</strong> </div> i have tried this:
$x('//div/span/text()') and array this:
["first element", " "] is there anyway get:
["first element", "second element"] and perhaps put python dictionary? , have:
dict = {'first element' : 'second element'} many helping
you can use following xpath :
//*[@id="details"]//div/*/text() or if want text nodes span , strong :
//*[@id="details"]//div/*[self::span|self::strong]/text() to skip empty text nodes, add predicate [normalize-space()] :
//*[@id="details"]//div/*/text()[normalize-space()] 
Comments
Post a Comment