Perhaps the easiest way is to not use ElementTree to process HTML, but to use BeautifulSoup instead; the library handles unwrapping explicitly through the .unwrap()
method:
for elem in soup.find_all('li'):
for para in elem.find_all('p'):
para.unwrap()
Top comments (0)