Last active
October 2, 2015 17:24
-
-
Save walkerdb/2db6e1f81e6eeba3a691 to your computer and use it in GitHub Desktop.
This file contains 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
# to find all unitid elements whose parent is a did tag: | |
tree.xpath("//did/unitid") | |
# using an absolute path to find exact locations: | |
tree.xpath("/ead/archdesc/did/physdesc/extent") | |
## if there are multiple "extent" tags in the parent physdesc, | |
## you can find specific tags by designating an index | |
## unlike any other language ever, xpath indexes start at 1, not zero | |
# returns a list containing the first extent in the parent physdesc | |
tree.xpath("/ead/archdesc/did/physdesc/extent[1]") | |
## You can also facet by tag attributes: | |
# finding all extent tags with an encodinganalog attribute | |
tree.xpath("//extent[@encodinganalog]) | |
# finding all container tags with a type attribute whose value is "box" | |
tree.xpath("//container[@type='box']") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment