R XML解析问题

时间:2015-05-14 20:54:06

标签: xml r

我正在尝试解析这样的XML结构:

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<Data xmlns=”data10.xsd” version=”1.1″>
<cmData scope=”all” type=”all”>
<header>
<log action=”created” appInfo=”XMLmanager” appVersion=”1.0″ dateTime=”2015-05-07″ user=”XXX”/>
</header>
<managedObject class=”Node” operation=”update” version=”1.0″>
<p name=”id”>Nd1</p>
<list name=”unitList”>
<item>
<p name=”primary”>IF1</p>
<p name=”Code”>A101</p>
<p name=”Name”>NQ</p>
<p name=”unitNumber”>1</p>
</item>
<item>
<p name=”primary”>IF1</p>
<p name=”Code”>A101</p>
<p name=”Name”>NX</p>
<p name=”unitNumber”>2</p>
</item>
</managedObject>
<managedObject class=”line” operation=”update” version=”1.0″>
<p name=”id”>Ln1</p>
<p name=”delay”>82</p>
<p name=”loss”>-30</p>
<p name=”ul”>0</p>
</managedObject>
</cmData>
</Data>

并且希望使数据框包含managedObject类,操作和可能的嵌套p名称值。 你能不能在这里暗示,因为我有一个xmlParse函数的问题:

> doc <- xmlParse(file)
xmlns: URI raml21.xsd is not absolute
> class(doc)
[1] “XMLInternalDocument” “XMLAbstractDocument”
> root = xmlRoot(doc)
> class(root)
[1] “XMLInternalElementNode” “XMLInternalNode” “XMLAbstractNode”
> child = xmlChildren(root)
> class(child)
[1] “XMLInternalNodeList” “XMLNodeList”
> child_next = xmlChildren(child)
Error in UseMethod(“xmlChildren”) :
no applicable method for ‘xmlChildren’ applied to an object of class “c(‘XMLInternalNodeList’, ‘XMLNodeList’)”
你可以帮忙理解为什么我不能获取子子课程吗?感谢您的帮助。

0 个答案:

没有答案