R: Insert node into xml tree at specific location
问题 Data I have an xml file with a structure like this (large example to show the needed flexibility): <rootnode sth="something" descr="ex"> <tag sth="sth1" descr="ex" anoAttr="sth2"> <tag sth="sth3" descr="ex2" searchA="sth4" anoAttr="sth5"> <tag sth="sth6" descr="ex3" oAttr="sth7" searchA="sth8" anoAttr="sth9"> <tag sth="sth10" descr="ex4" oAttr="sth11" searchA="sth12" anoAttr="sth13"> <someContent/> </tag> <someContent/> </tag> <tag sth="sth14" descr="ex5" oAttr="sth15" searchA="sth16" anoAttr