[R] Reading XML attriutes in R

Archit Soni soni.archit1989 at gmail.com
Thu Apr 27 12:08:39 CEST 2017


Hi All,

I have a XML file like :

<city id="2643743" name="London">
<coord lon="-0.13" lat="51.51"/>
<country>GB</country>
<sun rise="2017-01-30T07:40:36" set="2017-01-30T16:47:56"/>
</city>
<temperature value="280.15" min="278.15" max="281.15" unit="kelvin"/>
<humidity value="81" unit="%"/>
<pressure value="1012" unit="hPa"/>
<wind>
<speed value="4.6" name="Gentle Breeze"/>
<gusts/>
<direction value="90" code="E" name="East"/>
</wind>
<clouds value="90" name="overcast clouds"/>
<visibility value="10000"/>
<precipitation mode="no"/>
<weather number="701" value="mist" icon="50d"/>
<lastupdate value="2017-01-30T15:50:00"/>
</current>

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 issue now id to read XML attributes of different nodes and convert
it into a data frame, I have scraped many forums but could not find any
help in this.

For starters, please suggest a solution to parse the value of city node and
corresponding id, name, lat, long etc.

I know I am asking a lot, thanks for reading and cheers! :)

-- 
Regards
Archit

	[[alternative HTML version deleted]]



More information about the R-help mailing list