Thanks, I had to install BeautifulSoup4 even though I had BeautifulSoup installed. That works fine
When I used to code with other programming languages, I found the learning curve not as steep if I can use a 'debug' to inspect arrays and variables, etc. I see Python has pdb.
I see there are some GUI ones also - https://stackoverflow.com/posts/4929267/revisions
from bs4 import BeautifulSoup with open('testxml.xml', 'r') as f: file = f.read() soup = BeautifulSoup(file, 'xml') payee = soup.find('PAYEE') print(payee.attrs) ## All attributes print(payee['name']) # Get a single one print(payee.get('name')) # Or - get a single one address = soup.find('ADDRESS') print(address.attrs)python3 soup2.py
Output:{'matchingenabled': '0', 'email': '', 'name': 'Transfers - inter account', 'reference': '', 'id': 'P000001'}
Transfers - inter account
Transfers - inter account
{'street': '', 'telephone': '', 'county': '', 'city': '', 'zipcode': ''}
I will need to read up on how to loop through the array "payee" and print all or filter some. Also to learn how to reference what I call a data subset. For example "ADDRESS" is a data subset (child) of both PAYEE and INSTITUTION (data 'parents'). Quite a bit of learning and reading up.When I used to code with other programming languages, I found the learning curve not as steep if I can use a 'debug' to inspect arrays and variables, etc. I see Python has pdb.
I see there are some GUI ones also - https://stackoverflow.com/posts/4929267/revisions