Access specific elements

The eml_get() function is a powerful tool for exploring EML (more on that here ). It takes any chunk of EML and returns all instances of the element you specify. Note: you’ll have to specify the element of interest exactly, according to the spelling/capitalization conventions used in EML. Here are some examples:

doc <- read_eml(system.file("example-eml.xml", package = "arcticdatautils"))
eml_get(doc, "creator")
individualName:
  givenName: Bryce
  surName: Mecum
organizationName: National Center for Ecological Analysis and Synthesis
eml_get(doc, "boundingCoordinates")
eastBoundingCoordinate: '-134'
northBoundingCoordinate: '59'
southBoundingCoordinate: '57'
westBoundingCoordinate: '-135'
eml_get(doc, "url")
'':
  function: download
  url: ecogrid://knb/urn:uuid:89bec5d0-26db-48ac-ae54-e1b4c999c456
'': ecogrid://knb/urn:uuid:89bec5d0-26db-48ac-ae54-e1b4c999c456

eml_get_simple() is a simplified alternative to eml_get() that produces a list of the desired EML element.

eml_get_simple(doc$dataset$otherEntity, "entityName")

To find an eml element you can use either a combination of which_in_emlfrom the arcticdatautils package or eml_get_simple and which to find the index in an EML list. Use which ever workflow you see fit.

An example question you may have: Which creators have a surName “Mecum”?

Example using which_in_eml:

n <- which_in_eml(doc$dataset$creator, "surName", "Mecum")
# Answer: doc$dataset$creator[[n]]

Example using eml_get_simple and which:

ent_names <- eml_get_simple(doc$dataset$creator, "surName")
i <- which(ent_names == "Mecum")
# Answer: doc$dataset$creator[[i]]