Подскажите как удалить html разметку при парсинге xml файла
Пытаюсь собрать xlsx файл для дальнейшей работы из xml файла, но на выходе в блоке news_text присутствует большое количество html тегов с амперсандами. Подскажите как избавиться от всех html тегов учитывая, что в каждой строке они разные. В результате необходимо получить xlsx файл с 4 столбцами (с первыми тремя все ок) и в 4 столбце чистый текст без html тегов.
from bs4 import BeautifulSoup
import requests
import pandas as pd
fd = open('news.xml', 'r', encoding='utf-8')
xml_file = fd.read()
soup = BeautifulSoup(xml_file, features='lxml-xml')
#print(soup)
nid = soup.find_all('field', {'name': 'nid'})
date = soup.find_all('field', {'name': 'publ_date'})
title = soup.find_all('field', {'name': 'news_title'})
text = soup.find_all('field', {'name': 'news_text'})
currencies = []
for i in range(0, len(nid)):
rows = [nid[i].get_text(),
date[i].get_text(),
title[i].get_text(),
text[i].get_text()]
currencies.append(rows)
#display(currencies[:4])
news = pd.DataFrame(currencies,
columns=['Nid','Date','Title','Text'],
dtype=float)
news.to_excel('sgu.xlsx',
index=False)