Skip to content

Instantly share code, notes, and snippets.

@walkerdb
Created October 2, 2015 19:57
Show Gist options
  • Select an option

  • Save walkerdb/a31ef831e73f2ffab91c to your computer and use it in GitHub Desktop.

Select an option

Save walkerdb/a31ef831e73f2ffab91c to your computer and use it in GitHub Desktop.
# make a new, empty tag
>>> new_tag = etree.Element("extent")
# add some text
>>> new_tag.text = "25 embarrassing photos"
# add an attribute if you want any
>>> new_tag.attrib["encodinganalog"] = "300"
# insert the new tag into the master ead tree
# we'll use the parent element from last time
>>> parent.append(new_tag)
>>> print(etree.tostring(parent))
'''
<physdesc altrender="whole">
<extent encodinganalog="300">25 embarrassing photos</extent>
</physdesc>
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment