cannot modify text in a html tree
Bug #1755841 reported by
Tudor
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I'm on:
Python : sys.version_
lxml.etree : (4, 1, 1, 0)
libxml used : (2, 9, 7)
libxml compiled : (2, 9, 7)
libxslt used : (1, 1, 32)
libxslt compiled : (1, 1, 32)
I'm unable to modify the text located in the 'text3' position. I can find it using itertext() on the body element, but not much more.
from lxml import etree
from io import StringIO
orig_html = """
<html>
<body>
text1
<div align="center">
text2
</div>
text3
</body>
</html>
""".decode('utf8')
parser = etree.HTMLParser()
tree = etree.parse(
# how do i modify text3 into something else?
To post a comment you must log in.
Please don't use the bug tracker for user support requests. lxml.de/ tutorial. html#elements- contain- text
http://