tryCatch( xmlTreeParse("<a><b></a>", asText = TRUE, error = NULL),
XMLError = function(e) {
cat("There was an error in the XML at line",
e$line, "column", e$col, "",
e$message, "")
})
Run the code above in your browser using DataLab