[R] how to add a child to a child in XML

Bond, Stephen Stephen.Bond at cibc.com
Wed Mar 21 21:25:02 CET 2018

I am trying to add a child to a child using XML package in R. the following fails


node1 <- c("val1","val2","val3")

names(node1) <- c("att1","att2","att3")

root <- xmlNode("root", attrs=node1)

node2 <- LETTERS[1:3]

names(node2) <- paste("name",1:3,sep="")

root <- addChildren(root,xmlNode("child1",attrs=node2))

node3 <- letters[1:3]

names(node3) <- paste("name",4:6,sep="")

root <- addChildren(root$child1,xmlNode("child2",attrs=node3))

Error in UseMethod("addChildren") : no applicable method for 'addChildren' applied to an object of class "NULL"

Stephen B

	[[alternative HTML version deleted]]

More information about the R-help mailing list