Reputation: 39
//span[@class='cname']//text()[not(parent::em[@class='multiple']) and not(normalize-space()='')]
I need to remove text()
in this code. Because when I use text()
it becomes an object. But if I type ".text
" at the end of my python code it turns to element.
I need an element not an object. So I need to rewrite "text()
" from the code without any other changes, or change it from object to element.
Upvotes: 0
Views: 277
Reputation: 66723
If you want to select the parent element of that text()
you could just add /..
or /parent::*
to the end of the XPath
//span[@class='cname']//text()[not(parent::em[@class='multiple']) and not(normalize-space()='')]/..
or
//span[@class='cname']//text()[not(parent::em[@class='multiple']) and not(normalize-space()='')]/parent::*
Upvotes: 1