Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xmltodict
- import pprint
- if __name__ == '__main__':
- with open("xml_folder/country.xml") as ifile:
- text = ifile.read()
- # print(text)
- d = xmltodict.parse(text)
- # pprint.pprint(d)
- for country in d["countries"]["country"]:
- country["#text"] = country["#text"].upper()
- print(country["#text"])
- with open("xml_folder/country_3.xml", "w") as ofile:
- text = xmltodict.unparse(d, pretty=True)
- ofile.write(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement