htm.fromstring rogue parents
3 Nov
2016
3 Nov
'16
2:37 p.m.
Hello, Perhaps that's a very basic question, but I couldn't find the answer. lxml.html.fromstring adds implicit parents to the parsed element.
from lxml import html html.fragment_fromstring("<div>foo</div>").getroottree().getroot()
html.fragment_fromstring("<div>foo</div>").getparent()
How do I prevent this? ie I want .getparent() to return None and .getroottree().getroot() to return the top-level element. Best, Burak -- Python : sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0) lxml.etree : (3, 6, 4, 0) libxml used : (2, 9, 4) libxml compiled : (2, 9, 4) libxslt used : (1, 1, 29) libxslt compiled : (1, 1, 29)
2729
Age (days ago)
2729
Last active (days ago)
0 comments
1 participants
participants (1)
-
Burak Arslan