77# ' @param .value Optional character string to set as text content.
88# ' @return The newly created pugi_node.
99# ' @keywords internal
10- # ' @examples
11- # ' # doc <- read_xml("<root><child/></root>")
12- # ' # xml_add_child(doc, "new_node", id = "1", "Some text")
1310xml_add_child <- function (.x , .name , ... , .where = - 1 , .value = NULL ) {
1411 target <- if (is.list(.x )) .x [[1 ]] else .x
1512
@@ -45,8 +42,6 @@ xml_add_child <- function(.x, .name, ..., .where = -1, .value = NULL) {
4542# ' @param xpath Character string containing XPath expression.
4643# ' @return A pugi_node or list of nodes.
4744# ' @keywords internal
48- # ' @examples
49- # ' # xml_find_first(doc, ".//sheetData")
5045xml_find_first <- function (x , xpath ) {
5146 if (is.list(x )) return (lapply(x , xml_find_first , xpath = xpath ))
5247 if (! grepl(" ^\\ .|^/" , xpath )) xpath <- paste0(" .//" , xpath )
@@ -59,8 +54,6 @@ xml_find_first <- function(x, xpath) {
5954# ' @param xpath Character string containing XPath expression.
6055# ' @return A pugi_nodeset (list of pugi_nodes).
6156# ' @keywords internal
62- # ' @examples
63- # ' # xml_find_all(doc, ".//row")
6457xml_find_all <- function (x , xpath ) {
6558 if (is.list(x )) {
6659 res <- unlist(lapply(x , xml_find_all , xpath = xpath ), recursive = FALSE )
@@ -76,8 +69,6 @@ xml_find_all <- function(x, xpath) {
7669# ' @param x A pugi_node or list of nodes.
7770# ' @return A pugi_nodeset of child elements.
7871# ' @keywords internal
79- # ' @examples
80- # ' # xml_children(xml_find_first(doc, ".//row"))
8172xml_children <- function (x ) {
8273 if (is.list(x )) {
8374 res <- unlist(lapply(x , function (node ) .Call(C_pugi_children , node )), recursive = FALSE )
@@ -92,8 +83,6 @@ xml_children <- function(x) {
9283# ' @param x A pugi_node or list of nodes.
9384# ' @return A character vector of tag names.
9485# ' @keywords internal
95- # ' @examples
96- # ' # xml_name(xml_find_all(doc, "/*/*"))
9786xml_name <- function (x ) {
9887 if (is.list(x )) return (unname(sapply(x , function (node ) .Call(C_pugi_node_name , node ))))
9988 # Unwrap document node to its root element, matching xml2 behaviour
@@ -121,8 +110,6 @@ xml_type <- function(x) {
121110# ' @param attr Character string of the attribute name.
122111# ' @return A character vector of attribute values.
123112# ' @keywords internal
124- # ' @examples
125- # ' # xml_attr(rows, "r")
126113xml_attr <- function (x , attr ) {
127114 if (is.list(x )) return (unname(sapply(x , function (node ) .Call(C_pugi_get_attr , node , attr ))))
128115 .Call(C_pugi_get_attr , x , as.character(attr ))
@@ -134,8 +121,6 @@ xml_attr <- function(x, attr) {
134121# ' @param attr Character string of the attribute name.
135122# ' @param value The value to set (coerced to character).
136123# ' @keywords internal
137- # ' @examples
138- # ' # xml_set_attr(rows, "customHeight", "1")
139124xml_set_attr <- function (x , attr , value ) {
140125 if (is.list(x )) {
141126 invisible (lapply(x , function (node ) .Call(C_pugi_set_attr , node , attr , as.character(value ))))
@@ -150,8 +135,6 @@ xml_set_attr <- function(x, attr, value) {
150135# ' @param attr Character string of the attribute name.
151136# ' @return A logical vector.
152137# ' @keywords internal
153- # ' @examples
154- # ' # has_r <- xml_has_attr(cells, "r")
155138xml_has_attr <- function (x , attr ) {
156139 if (is.list(x )) return (unname(sapply(x , function (node ) .Call(C_pugi_has_attr , node , attr ))))
157140 .Call(C_pugi_has_attr , x , as.character(attr ))
@@ -162,8 +145,6 @@ xml_has_attr <- function(x, attr) {
162145# ' @param x A pugi_node or list of nodes.
163146# ' @return An integer vector of child counts.
164147# ' @keywords internal
165- # ' @examples
166- # ' # xml_length(doc)
167148xml_length <- function (x ) {
168149 if (is.list(x )) return (unname(sapply(x , function (node ) .Call(C_pugi_node_length , node ))))
169150 .Call(C_pugi_node_length , x )
@@ -173,8 +154,6 @@ xml_length <- function(x) {
173154# '
174155# ' @param x A pugi_node or list of nodes.
175156# ' @keywords internal
176- # ' @examples
177- # ' # xml_remove(xml_find_all(doc, ".//legacyDrawing"))
178157xml_remove <- function (x ) {
179158 if (is.list(x )) invisible (lapply(x , function (node ) .Call(C_pugi_remove , node )))
180159 else if (! is.null(x )) .Call(C_pugi_remove , x )
0 commit comments