a vector or list of character strings containing one or more XML paths.
default
a character string providing a default return value for invalid paths.
delimiters
character string specifying the delimiter to use when
parsing.
separateDelimiters
a logical value. If
T, successive delimiters will create an empty value.
VALUE:
a named list of character vectors with one list element for each string
in the argument
path, where the names of the list
elements are the
path strings. Each list element
contains the parsed strings corresponding to a XML path string.
# Create an XML string and parse for specific XML paths
x <- paste("<library>",
"<book id=\"web1\">",
"<title>Dictionary</title>",
"</book>",
"<book id=\"web2\">",
"<title>Spanish 2 English</title>",
"</book>",
"<book id=\"1\">",
"<title>Encyclopedia - A</title>",
"</book>",
"<book id=\"2\">",
"<title>Encyclopedia - B</title>",
"</book>",
"</library>", sep=" ")
xpaths <- c("library/book/@id",
"library/book/title/text()",
"library/book[@id = 'web1']/title/text()",
"library/book[@id < 2]/title/text()")
parseXMLPathString(x, xpaths)
# Create an XML string for an S-PLUS data frame and parse with an XML path
xmls <- createXMLString(fuel.frame)
parseXMLPathString(xmls, "S-PLUS/DataFrame/RowNames/Items/Item/text()")
# Create an XML string for an S-PLUS vector using a delimiter and parse
x <- 1:5
annotation <- "An example of an XML string with a delimiter"
del <-","
xmls <- createXMLString(x, delimiter=del)
# get "1,2,3,4,5"
parseXMLPathString(xmls, "S-PLUS/Vector/Items/text()")
# get an character vector: [1] "1" "2" "3" "4" "5"
parseXMLPathString(xmls, "S-PLUS/Vector/Items/text()", delimiters=del)