1

我想我正在处理从 MAC 系统导出的一些数据文件。我收到了一个文件名 20110205.tar,然后我尝试查看里面的内容,它只给了我原始文件?BIN。我的朋友帮我提取了一堆xml文件,名称为时间格式:“2011-03-15T23_57_59Z.xml”,“2011-03-15T23_58_00Z.xml”。我尝试使用带有 xmlTree、xmlTreeParse、asXMLNode 等命令的 XML 包,然后我完全卡住了。当我通过记事本打开 xml 文件时,我有类似的东西:(我的朋友使用 Python 来做到这一点,但我不知道 Python)我也尝试了一些像 epidata 这样的包,但似乎很多包都不能用于更多。提取的文件我做winrar并上传到mediafire: http ://www.mediafire.com/?ot8vt0wdw5c3oc1 <asdiOutput xmlns="http://tfm.faa.gov/tfms/TFMS_XIS" xmlns:nxce="http://tfm.faa.gov/tfms/NasXCoreElements" xmlns:mmd="http://tfm.faa.gov/tfms/MessageMetaData" xmlns:nxcm="http://tfm.faa.gov/tfms/NasXCommonMessages" xmlns:idr="http://tfm.faa.gov/tfms/TFMS_IDRS" xmlns:xis="http://tfm.faa.gov/tfms/TFMS_XIS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tfm.faa.gov/tfms/TFMS_XIS http://localhost:58489/tfms/schema/TFMS_XIS.xsd" timestamp="2011-03-15T23:57:59Z"> <asdiMessage sourceFacility="CCZM" sourceTimeStamp="2011-03-15T23:57:27Z" trigger="TZ"> <trackInformation> <nxcm:aircraftId>UAL966</nxcm:aircraftId> <nxcm:speed>470</nxcm:speed> <nxcm:reportedAltitude> <nxce:assignedAltitude> <nxce:simpleAltitude>350</nxce:simpleAltitude> </nxce:assignedAltitude> </nxcm:reportedAltitude> <nxcm:position> <nxce:latitude> <nxce:latitudeDMS degrees="45" minutes="40" direction="NORTH"/> </nxce:latitude> <nxce:longitude> <nxce:longitudeDMS degrees="056" minutes="58" direction="WEST"/> </nxce:longitude> </nxcm:position> </trackInformation> </asdiMessage> <asdiMessage sourceFacility="CCZM" sourceTimeStamp="2011-03-15T23:57:27Z" trigger="TZ"> <trackInformation> <nxcm:aircraftId>UAL936</nxcm:aircraftId> <nxcm:speed>470</nxcm:speed> <nxcm:reportedAltitude> <nxce:assignedAltitude> <nxce:simpleAltitude>350</nxce:simpleAltitude> </nxce:assignedAltitude> </nxcm:reportedAltitude> <nxcm:position> <nxce:latitude> <nxce:latitudeDMS degrees="44" minutes="43" direction="NORTH"/> </nxce:latitude> <nxce:longitude> <nxce:longitudeDMS degrees="062" minutes="42" direction="WEST"/> </nxce:longitude> </nxcm:position> </trackInformation> </asdiMessage>

请任何人帮助我。我想在 R 中做任何事情。 1. 提取 tar 文件并将原始文件解码为 xml 文件 2. 读取提取的多个 xml 中的数据提前谢谢!!!

4

1 回答 1

1

根据您的操作系统,Runtar命令可能会有所帮助;见?untar。作为使用 XML 的示例,我们可以加载文档

library(XML)
xml = xmlParse("2011-03-15T23_57_59Z.xml")

然后使用xpath语言查询它(特别是参见第 2.5 节),例如,飞机 id 和经度

> xpathSApply(xml, "//nxcm:aircraftId", xmlValue)
[1] "UAL966" "UAL936"
> xpathSApply(xml, "//nxce:longitudeDMS/@degrees")
degrees degrees 
  "056"   "062" 

还有一些便利功能,例如xmlToDataFrame,探索起来可能很有趣。

于 2013-02-03T03:14:49.450 回答