0
//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.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147

1 Answers1

1

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::*
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147