I am using lxml to parse a sample html. like this:
__dom = lxml.html.fromstring("<html><body><div id='mydiv'></div></body></html>")
I am trying to get the id of an element that I added to the html programatically, like this:
mydiv = __dom.get_element_by_id('mydiv')
mydiv.text = "<p id='myInner'>this is the inner inner text</p>"
myInner= __dom.get_element_by_id("myInner")
When adding the P it IS added. But when trying to get it back with get_element_by_id I am getting keyError on myInner.
I am guessing that since I added the P as text - it is no parsed as an HTML element and therefore I can not get it.
So my question is really: How to add/modify the innerHTML of an element using lxml?
Thanks