r - XML elements to list XML objects -
how split xml tree list of xml objects , user function getnodeset return value should include root object "part"?
require(xml) txt = "<doc> <part> <name>abc</name> <type>xyz</type> <cost>3.54</cost> <status>available</status> </part> <part> <name>abc</name> <type>xyz</type> <cost>3.54</cost> <status>available</status> </part> </doc>" doc <- xmltreeparse(txt, useinternalnodes = true) special_nodes <- getnodeset(doc, "/*/part//*")
i think nodes returned getnodeset
pointers underlying xml object, instance
> special_nodes[[1]] <name>abc</name> > xpathsapply(special_nodes[[1]], "../cost") [[1]] <cost>3.54</cost>
Comments
Post a Comment