I have this code using the R library flat XML which takes an XML and processes it in a way that fits my needs perfectly.
doc = fxml_importXMLFlat("hospit