下面是我需要解析的示例XML文件。這只是文件的一部分,原始文件非常大。但是格式總是一樣的。如何讀取R中xml的特定屬性
我只想解析這些值並將其放入數據框中。
<Property Name="Entity1ID" Type="Edm.String">
<Annotation Term="test.Label">
<String>IDENTIFIER</String>
</Annotation>
</Property>
所以在數據幀我應該有這樣
Entity1ID -> IDENTIFIER
ID -> FILEID
Entity2ID -> ID
等所有的值...
有大約10的EntityType和1000屬性標記,我只需要解析屬性標記並映射值。
我無法解析這些值。我知道這將是一個小程序,但是,我對R是新手。
在此先感謝。
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:Data>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="test.Models" Alias="test">
<EntityType Name="Entity1">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="Entity1ID" Type="Edm.String">
<Annotation Term="test.Label">
<String>IDENTIFIER</String>
</Annotation>
</Property>
<Property Name="ID" Type="Edm.String">
<Annotation Term="test.Label">
<String>FILEID</String>
</Annotation>
</Property>
<NavigationProperty Name="Subjects" Type="Collection(test.Subjects)"/>
</EntityType>
<EntityType Name="Entity2">
<Key>
<PropertyRef Name="Entity2ID"/>
</Key>
<Property Name="Entity2ID" Type="Edm.String">
<Annotation Term="test.Label">
<String>ID</String>
</Annotation>
</Property>
</EntityType>
<Function Name="GetData" EntitySetPath="asphalt/Entity2" IsBound="true">
<Parameter Name="asphalt" Type="test.asphalt" Nullable="false"/>
<Parameter Name="ID" Type="Edm.String"/>
<ReturnType Type="Collection(test.Entity2)" Nullable="false"/>
</Function>
<Term Name="Label" Type="Edm.String"/>
<EntityContainer Name="API">
<EntitySet Name="Studies" EntityType="test.Entity1"/>
</EntityContainer>
</Schema>
</edmx:Data>
</edmx:Edmx>
那你試試,沒有工作?」 – hrbrmstr