Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

xmlSearchNs

Find a namespace definition object by searching ancestor nodes


Description

This function allows one to search an XML tree from a particular node and find the namespace definition for a given namespace prefix or URL. This namespace definition can then be used to set it on a node to make it the effective namespace for that node.

Usage

xmlSearchNs(node, ns, asPrefix = TRUE, doc = as(node, "XMLInternalDocument"))

Arguments

node

an XMLInternaElementNode

ns

a character string (vector of length 1). If asPrefix is TRUE, this is the namespace alias/prefix. If asPrefix is FALSE, this is the URL of the namespace definition

asPrefix

a logical value. See ns.

doc

the XML document in which the node(s) are located

Value

An object of class XMLNamespaceRef.

Author(s)

Duncan Temple Lang

References

libxml2

See Also

Examples

txt = '<top xmlns:r="http://www.r-project.org"><section><bottom/></section></top>'

 doc = xmlParse(txt)
 bottom = xmlRoot(doc)[[1]][[1]]
 xmlSearchNs(bottom, "r")

XML

Tools for Parsing and Generating XML Within R and S-Plus

v3.99-0.10
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Tomas Kalibera [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.