How to generate a xml from a data.frame R -


i generate xml file dataframe in r. here example :

data.frame

x y z 1 2 'bla' 3 4 'blou' 5 7 'bli' 

xml result :

  <xml>     <tuple x="1" y="2" z="bla" \>     <tuple x="3" y="4" z="blou" \>     <tuple x="5" y="7" z="bli" \>  </xml> 

maybe helps:

d <- data.frame(x=1:3, y=3:5, z=c("foo", "bar", "baz")) cat(paste("<xml>", paste('<tuple x="', d$x, '" y="', d$y, '" z="', d$z, '" \\>"', sep="", collapse="\n"), "</xml>", sep="\n"), "\n") ## <xml> ## <tuple x="1" y="3" z="foo" \>" ## <tuple x="2" y="4" z="bar" \>" ## <tuple x="3" y="5" z="baz" \>" ## </xml>  

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -