Jul-07-2023, 01:21 AM
I needed to specify 'parent'. On a find_all() it wouldn't work, but on a find() it worked
#!/usr/bin/python from bs4 import BeautifulSoup with open('testxml.xml', 'r') as f: file = f.read() soup = BeautifulSoup(file, 'xml') for tag in soup.find('PAYEE').parent: print(tag) print('finished')