I am learning lxml, the code is as follows:
from lxml import etree text = ''' ''' html = etree.HTML(text) print(etree.tostring(html,encoding='utf-8').decode('utf-8'))
The output is as follows:
Mainly I don’t understand why there is an error in thetag? How to solve this problem? Thank you~
Mainly because
p element
Content classification Flow content, palpable content.
Allowed content Phrasing content.
Allowed parent elements Any element that accepts flow content
i Element
Content catergories Flow content, phrasing content, palpable content.
Allowance phrasing content.
Obviously the parent element of the P element should be of flow content type, but i does not meet the conditions, which means it does not comply with the specification.
The solution is to replace i directly with p.