from bs4 import BeautifulSoup
with open('input.xml', 'rb') as file:
    soup = BeautifulSoup(file)
Iterate through elements in html tree using BeautifulSoup, and produce an output that maintains the relative position of each element? in Python