Created
October 5, 2015 14:56
-
-
Save walkerdb/54b5f4923738d6481419 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create a new parser object | |
| parser = etree.XMLParser(remove_blank_text=True) | |
| # when we parse the input file, add a parser argument | |
| tree = etree.parse("path/to/ead.xml", parser=parser) | |
| [... making edits ...] | |
| # when making the output string, add a new pretty_print argument | |
| ead_text = etree.tostring(tree, pretty_print=True, xml_declaration=True, encoding="utf-8") | |
| # write the file | |
| with open(os.path.join("path/to/ead/directory", "ead_filename.xml"), mode="w") as f: | |
| f.write(ead_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment