Still learning lxml. I discovered that sometimes I cannot get to the text of an item from a tree using item.text. If I use item.text_content() I am good to go. I am not s
You maybe confusing different and incompatible interfaces that lxml
implements -- the lxml.etree
items have a .text
attribute, while (for example) those from lxml.html implement the text_content
method (and those from BeautifulSoup, also included in lxml
, have a .string
attribute... sometimes [[only nodes with a single child which is a string...]]).
Yeah, it is inherently confusing that lxml
chooses both to implement its own interfaces and emulate or include other libraries, but it can be convenient...;-).