xmlDOMApply(XML)
xmlDOMApply()所属R语言包:XML
Apply function to nodes in an XML tree/DOM.
应用在XML树/ DOM节点的功能。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This recursively applies the specified function to each node in an XML tree, creating a new tree, parallel to the original input tree. Each element in the new tree is the return value obtained from invoking the specified function on the corresponding element of the original tree. The order in which the function is recursively applied is "bottom-up". In other words, function is first applied to each of the children nodes first and then to the parent node containing the newly computed results for the children.
递归适用于指定的函数在XML树中的每个节点,创建一个新的树,平行于原始输入树。新的进化树中的每个元素调用指定的函数的返回值获得相应的元素原树。在该函数的递归应用的顺序是“自下而上”。换句话说,函数首先被施加到各子节点的第一,然后,对父节点包含的新计算的结果为孩子。
用法----------Usage----------
xmlDOMApply(dom, func)
参数----------Arguments----------
参数:dom
a node in the XML tree or DOM on which to recursively apply the given function. This should not be the XMLDocument itself returned from xmlTreeParse but an object of class XMLNode. This is typically obtained by calling xmlRoot on the return value from xmlTreeParse.
在XML树中或DOM节点上以递归应用的功能。这不应该是XMLDocument,本身返回xmlTreeParse但一个类XMLNode的对象。这通常是通过调用的返回值xmlRootxmlTreeParse。
参数:func
the function to be applied to each node in the XML tree. This is passed the node object for the and the return value is inserted into the new tree that is to be returned in the corresponding position as the node being processed. If the return value is NULL, this node is dropped from the tree.
函数被应用到XML树中的每个节点。这是传递和返回值被插入到正在处理的节点在相应的位置将被返回的新树的节点对象。如果返回值是NULL,这个节点从树中删除。
Details
详细信息----------Details----------
This is a native (C code) implementation that understands the structure of an XML DOM returned from xmlTreeParse and iterates over the nodes in that tree.
这是一个本地(C代码)实现,从xmlTreeParse知道返回的XML DOM结构和遍历,树中的节点。
值----------Value----------
A tree that parallels the structure in the dom object passed to it.
一棵树平行的结构dom对象传递给它。
(作者)----------Author(s)----------
Duncan Temple Lang
参考文献----------References----------
参见----------See Also----------
xmlTreeParse
xmlTreeParse
实例----------Examples----------
dom <- xmlTreeParse(system.file("exampleData","mtcars.xml", package="XML"))
tagNames <- function() {
tags <- character(0)
add <- function(x) {
if(inherits(x, "XMLNode")) {
if(is.na(match(xmlName(x), tags)))
tags <<- c(tags, xmlName(x))
}
NULL
}
return(list(add=add, tagNames = function() {return(tags)}))
}
h <- tagNames()
xmlDOMApply(xmlRoot(dom), h$add)
h$tagNames()
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|