For example fileName <- system.file("exampleData", "mtcars.xml", package="XML") doc <- xmlTreeParse(fileName) r<-xmlRoot(doc) record<-r[["record"]] record the result : <record id="Mazda RX4">21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4</record> but in the mecars.xml there are 32 sub-nodes called "record"
when I use xmlChildren function c<-xmlChildren(r)[["record"]] c is also like that <record id="Mazda RX4">21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4</record> just the first sub-node is the default My question is: Is there a function that can get the sub-node according to the sub-node's attribute ? like that,in the mtcar.xml ,there is sub-node as follow: <record id="Lotus Europa"> 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2</record> I want to get the specific sub-node according to the attribute "id="Lotus Europa". Is there a simple function in the xml package? -- ºÎÁÁ Öйú¿ÆÑ§Ôº´óѧ µØÀí¿ÆÑ§Óë×ÊÔ´Ñо¿Ëù ½µØË®Ñ»·ÓëµØ±í¹ý³ÌÖØµãʵÑéÊÒ ±±¾©ÊÐ ³¯ÑôÇø ´óÍÍ·¼×11ºÅ µç»°£º13651318417 Liang He Institute of Geographic Sciences and Natural resource research Chinese Academy of Science, No.11, Datun Road, Chaoyang District, Beijing 100101, China Email: xhl860...@163.com Tel: +86(10) 6488 9513 Mob:+86 0 13651318417 [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.