How to load the XML files from directory please

princi

New Member
This code I got somewhere on internet and I edited it.How can I load the XML file from my directory? Is there any way to do this?\[code\]from elementtree import ElementTree as et# Load the xml content from a stringcontent = et.fromstring("C:\DATA\US_Patent_Data\2012\ipgb20120103_wk01\ipgb20120103.xml")# Get the person or use the .findall method to get all# people if there's more than personapplicant = content.find("applicant")last_name = applicant.find("addressbook/last-name")first_name = applicant.find("addressbook/first-name")# Get the persons addressaddress = addressbook.find("address")street = address.find("street")city= address.find("city")state = address.find("state")postcode = address.find("postcode")country = address.find("country")# Print outputprint "sequence: " + applicant.attrib.get('sequence')print "first name: " + first_name.textprint "last name: " + last_name.textprint "street: " + street.textprint "city: " + city.textprint "state: " + state.textprint "postcode: " + postcode.textprint "country: " + country.text\[/code\]I ran the program this is what I got.I copied part of them...\[code\] File "C:\Python27\lib\site-packages\elementtree\ElementTree.py", line 1292, in feedself._parser.Parse(data, 0)\[/code\]ExpatError: not well-formed (invalid token): line 1, column 2
 
Top