xmlGetAttr(XML)
xmlGetAttr()所属R语言包:XML
Get the value of an attribute in an XML node
在一个XML节点的属性值
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This is a convenience function that retrieves the value of a named attribute in an XML node, taking care of checking for its existence. It also allows the caller to provide a default value to use as the return value if the attribute is not present.
这是一个方便的功能,在一个XML节点的命名属性检索值,检查其存在的照顾。它还允许调用者提供一个默认值,使用的返回值,如果这个属性是不存在的。
用法----------Usage----------
xmlGetAttr(node, name, default = NULL, converter = NULL,
namespaceDefinition = character(),
addNamespace = length(grep(":", name)) > 0)
参数----------Arguments----------
参数:node
the XML node
XML节点
参数:name
the name of the attribute
的属性的名称
参数:default
a value to use as the default return if the attribute is not present in the XML node.
一个值,如果使用默认的返回的XML节点的属性是不存在的。
参数:converter
an optional function which if supplied is invoked with the attribute value and the value returned. This can be used to convert the string to an arbitrary value which is useful if it is, for example, a number. This is only called if the attribute exists within the node. In other words, it is not applied to the default value.
一个可选的功能,如果提供的属性值调用和返回值。这可以被用来将字符串转换为任意的值,这是有用的,如果它是,例如,一个数字。这仅仅是如果该属性存在于节点调用。换句话说,它不施加到default值。
参数:namespaceDefinition
a named character vector giving name space prefixes and URIs to use when resolving for the the attribute with a namespace. The values are used to compare the name space prefix used in the name given by the user to the name space definition in the node to ensure they match. This is important as we might ask for an attribute named r:width assuming that the prefix r corresponded to the URI http://www.r-project.org. However, there may be a name space prefix r defined on the node that points to a different URI and so this would be an erroneous match.
给一个指定的字符向量的名称空间前缀和URI的属性与命名空间时使用的解决。这些值用于比较name由用户给定的节点中,以确保它们匹配的名称空间定义中所用的名称空间前缀。这是很重要的,因为我们可能会问名为r:width的前缀r对应的URI http://www.r-project.org的属性。然而,有可能是一个名称空间前缀r上定义的节点指向到不同的URI,所以这将是一个错误的匹配。
参数:addNamespace
a logical value that indicates whether we should put the namespace prefix on the resulting name. This is passed on to xmlAttrs and so controls whether the resulting attribute names have the prefix attached. So one specifies TRUE for this argument if the attribute identifier has a namespace prefix.
一个逻辑值,指明是否我们应该把命名空间前缀的名称。这是传递给xmlAttrs和控制得到的属性名是否有附加的前缀。因此,一个指定TRUE这种说法,如果属性标识符的命名空间前缀。
Details
详细信息----------Details----------
This just checks that the attribute list is non-NULL and that there is an element with the specified name.
这只是检查,属性列表非空,并且有一个具有指定名称的元素。
值----------Value----------
If the attribute is present, the return value is a string which is the value of the attribute. Otherwise, the value of default is returned.
如果该属性存在,则返回值是一个字符串,它的值的属性。否则,该值default返回。
(作者)----------Author(s)----------
Duncan Temple Lang
参考文献----------References----------
参见----------See Also----------
xmlAttrs
xmlAttrs
实例----------Examples----------
node <- xmlNode("foo", attrs=c(a="1", b="my name"))
xmlGetAttr(node, "a")
xmlGetAttr(node, "doesn't exist", "My own default value")
xmlGetAttr(node, "b", "Just in case")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|