Re: [R] Reading XML attriutes in R

2017-04-28 Thread Archit Soni
Thanks Ben, I'll give it a shot.. Thanks again :) On Apr 28, 2017 18:54, "Ben Tupper" wrote: > Hi again, > > It would be super easy if xml2::xml_attrs() accepted a list of attribute > names and defaults values like xml2::xml_attr() does, but it doesn't. Once > you have a

Re: [R] Reading XML attriutes in R

2017-04-28 Thread Ben Tupper
Hi again, It would be super easy if xml2::xml_attrs() accepted a list of attribute names and defaults values like xml2::xml_attr() does, but it doesn't. Once you have a list of character vectors like that returned by your ... ppt <- x %>% xml_find_all("precipitation") %>% xml_attrs() ..then

Re: [R] Reading XML attriutes in R

2017-04-28 Thread Archit Soni
Thanks Ben, got it working, just want one more help on this, If i have a node like: and in some other city it came like: How can i make my code to handle this dynamically? I am sorry to ask such novice questions but it would be extremely helpful if you could help me with this. So, i would

Re: [R] Reading XML attriutes in R

2017-04-27 Thread Ben Tupper
Hi, There might be an easy solution out there already, but I suspect that you will need to parse the XML yourself. The example below uses package xml2 not XML but you could do this with either. The example simply shows how to get values out of the XML hierarchy. Once you have the attributes

[R] Reading XML attriutes in R

2017-04-27 Thread Archit Soni
Hi All, I have a XML file like : GB I want to create a data frame out of this XML but obviously xmlToDataFrame() is not working. It has dynamic attributes like for node precipitation , it could have attributes like value and mode both if there is ppt in some city. My basic