Learn R Programming

flatxml (version 0.1.1)

fxml_getParent: Parent of an XML element

Description

Returns the parent of an XML element.

Usage

fxml_getParent(xmlflat.df, elemid)

Arguments

xmlflat.df

A flat XML dataframe created with fxml_importXMLFlat.

elemid

The ID of the XML element. The ID is the value of the elemid. field in the flat XML dataframe.

Value

The ID (xmlflat.df$elemid.) of the parent node of the XML element with ID elemid. If no parent exists (because XML node elemid is the root node of the XML document) then NULL is returned.

See Also

fxml_hasParent

Examples

Run this code
# NOT RUN {
# 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)

# Get the ID of the parent element of the XML element with ID 4 (xml.dataframe$elemid. ==  4)
fxml_getParent(xml.dataframe, 4)
# }

Run the code above in your browser using DataLab