将属性从 xml 提取到 R 时出现问题。我的 xml 文件如下:
- <export>
+ <ExportRef>
- <BookNodes>
- <Book label="romance">
+ <Showing>
- <Data>
+ <Char1 label="Char1">
- <Char2 label="Char2">
+ <SubChar21>
- <SubChar22>
<Range unit="nm">4</Range>
<Range unit="nm">8</Range>
</SubChar22>
- <Char3 label="Char3">
+ <SubChar31>
- <SubChar32>
<Range Id="1">voc</Range>
<Range Id="2">buc</Range>
</SubChar32>
</Data>
</Book>
- <Book label="horror">
+ <Showing>
- <Data>
+ <Char1 label="Char1">
- <Char2 label="Char2">
+ <SubChar21>
- <SubChar22>
<Range unit="nm">4</Range>
<Range unit="nm">8</Range>
</SubChar22>
- <Char3 label="Char3">
+ <SubChar31>
- <SubChar32>
<Range Id="1">voc</Range>
<Range Id="2">buc</Range>
</SubChar32>
</Data>
</Book>
</BookNodes>
</export>
我想为每个图书类别列出一个范围 ID 列表。例如:
浪漫:
id id
1 2
恐怖:
id id
1 2
当我做这样的事情时:
RangeID_1<-xpathSApply(AC_Node[[1]][[2]], ".//Range", xmlAttrs)
我得到:
unit unit id id
"nm" "nm" "1" "2"
如何对 R 说我只想要 Range Id 而不是 Range 单位?
非常感谢!!