https://github.com/cran/XML
Tip revision: 18262cc246d37d4b4131be097abad3f5ef98dae7 authored by Duncan Temple Lang on 07 March 2013, 00:00:00 UTC
version 3.95-0.2
version 3.95-0.2
Tip revision: 18262cc
xpath.R
xpathExprCollector =
function(targetAttributes = c("test", "select"))
{
# Collect a list of attributes for each element.
tags = list()
# frequency table for the element names
counts = integer()
start =
function(name, attrs, ...) {
attrs = attrs[ names(attrs) %in% targetAttributes ]
if(length(attrs) == 0)
return(TRUE)
tags[names(attrs)] <<-
lapply(names(attrs),
function(id)
c(tags[[id]] , attrs[id]))
}
list(.startElement = start,
.getEntity = function(x, ...) "xxx",
.getParameterEntity = function(x, ...) "xxx",
result = function() lapply(tags, function(x) sort(table(x), decreasing = TRUE)))
}