https://github.com/cran/XML
Tip revision: f7e67b5b2cdaea178e53e8a8d55e319a9be2a6e0 authored by Duncan Temple Lang on 29 November 2011, 00:00:00 UTC
version 3.6-1
version 3.6-1
Tip revision: f7e67b5
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)))
}