我需要从xml文件中提取数据并绘制图形:深度与时间戳.标题应该是IFC代码.我尝试使用xmlToList和xmlTodataframe,但我没有这样做.我需要帮助.我的xml文件看起来像
<document>
<site>
<IFC_code>HONEYCR01</IFC_code>
<Latitude>41.960161</Latitude>
<Longitude>-90.470759</Longitude>
<River>Honey Creek</River>
<Road>Hwy 136, 1st Street</Road>
<Town>Charlotte</Town>
<from_sensor_to_river_bottom>9.35</from_sensor_to_river_bottom>
<Unit>foot</Unit>
</site>
<data>
<value>
<timestamp>2012-05-17 15:30:03-05</timestamp>
<depth>8.53</depth>
</value>
<value>
<timestamp>2012-05-17 14:30:06-05</timestamp>
<depth>8.50</depth>
</value>
<value>
<timestamp>2012-05-17 14:15:02-05</timestamp>
<depth>8.51</depth>
</value>
<value>
<timestamp>2012-05-17 14:00:12-05</timestamp>
<depth>8.50</depth>
</value>
<value>
<timestamp>2012-05-17 13:45:08-05</timestamp>
<depth>8.51</depth>
</value>
</data>
</document>
Run Code Online (Sandbox Code Playgroud)
它似乎工作:
library(XML)
doc <- xmlParse("a.xml")
xmlToDataFrame(
getNodeSet(doc, "//value"),
colClasses=c("character","numeric")
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5266 次 |
| 最近记录: |