If you look at my answer in your other thread,you can use that code.
I see no point in using Minidom
I see no point in using Minidom
from bs4 import BeautifulSoup data = '''\ <Name>Tim</Name> <Age>23</Age> <Number>1234</Number> <Name>Jenny</Name> <Age>23</Age> <Number>4321</Number>''' soup = BeautifulSoup(data, 'lxml') for item in soup.find_all(['name', 'age', 'number']): print(f'{item.name.capitalize()}:{item.text}')
Output:Name:Tim
Age:23
Number:1234
Name:Jenny
Age:23
Number:4321