Finds all XML elements in an XML document that lie on a certain path. Search starts from the root node of the XML document. Sub-elements (children) of the elements on the search path are returned, too.
A flat XML dataframe created with
A character vector representing the path to be searched. Each element of the vector is a hierarchy level in the XML document. Example:
A list of named vectors representing attribute/value combinations the XML elements on the search path must match.
The name of an element in the list is the XML elment name to which the attribute belongs. The list element itself is a named vector.
The vector's elements represent different attributes (= the names of the vector elements) and their values (= vector elements).
A list of vectors representing attribute/value combinations the XML elements on the search path must not match to be included in the results. See argument
fxml_findPathRoot(), the search always starts at the root node of the XML document. If, for example,
path = c("tag1", "tag2") then
the element with full XML path
<xml><testdoc><tag1><tag2> would not be found, only if search path were
c("xml", "testdoc", "tag1", "tag2")
fxml_findPath...() functions allow for different search modes:
fxml_findPath: Search for path anywhere in the XML document (not necessarily starting at the root node). Sub-elements are returned, too.
fxml_findPathFull: Search for exact path (always starting from the root node). No sub-elements returned, as they have a different path than the search path.
fxml_findPathBottom: Search for path from the bottom of the element hierarchy in the XML document.
The IDs (
xmlflat.df$elemid.) of the XML elements that are located on the provided path. Sub-elements of the elements on the search path are returned, too.
NULL, if no elements where found.
Joachim Zuckarelli [email protected]
1 2 3 4 5 6 7 8 9 10 11 12 13
# Load example file with population data from United Nations Statistics Division # and create flat dataframe example <- system.file("worldpopulation.xml", package="flatxml") xml.dataframe <- fxml_importXMLFlat(example) # Find all XML elements that have a path starting with <root><data><record><field> path <- c("root", "data", "record", "field") fxml_findPathRoot(xml.dataframe, path) # Find all XML elements that have a path starting with <root><data><record><field>, but only # those which have the "name" attribute of the <field> element set to "Sex" path <- c("root", "data", "record", "field") fxml_findPathRoot(xml.dataframe, path, attr.only = list(field = c(name = "Sex")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.