xml到r数据提取

xml到r数据提取,xml,r,xml-parsing,Xml,R,Xml Parsing,我需要从xml文件中提取数据并绘制以下图形: 深度与时间戳。标题应为IFC代码。我尝试使用xmlToList和xmlTodataframe,但失败了。我需要帮助。我的xml文件看起来像 <document> <site> <IFC_code>HONEYCR01</IFC_code> <Latitude>41.960161</Latitude> <Longitude&g

我需要从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>

蜂蜜CR01
41.960161
-90.470759
哈尼克里克
第一街136号高速公路
夏洛特
9.35
脚
2012-05-17 15:30:03-05
8.53
2012-05-17 14:30:06-05
8.50
2012-05-17 14:15:02-05
8.51
2012-05-17 14:00:12-05
8.50
2012-05-17 13:45:08-05
8.51
这似乎有效:

library(XML)
doc <- xmlParse("a.xml")
xmlToDataFrame(
  getNodeSet(doc, "//value"),
  colClasses=c("character","numeric")
)
库(XML)

医生,什么不起作用?你收到了什么错误消息?如果我想画一个图表:从传感器到河流底部与时间?你必须将时间戳从字符串转换为实际时间戳。如果可以丢弃时间戳末尾的
-05
,则可以使用
库(stringr);d$时间戳谢谢你那帮了大忙。。我们能做一些算术运算,比如在:{(从传感器到河底)-(深度)}和时间之间画一张图吗?我必须承认你是个天才!!向您致敬您可以使用
xpathsaply
xmlValue
y提取值。非常感谢您:)我真的很感谢你的帮助,这些天我可能会发布更多的问题。。我希望你能回答。。