R programming language resources › Forums › Data manipulation › XML parsing issue
- This topic has 0 replies, 1 voice, and was last updated 9 years, 9 months ago by
klumpakojis.
- AuthorPosts
- May 14, 2015 at 8:16 pm #1110
klumpakojis
Memberhi Gurus,
I am trying to parse such XML structure:<?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>And want to make such data frame:
managedObject Operation name Value
Node update id Nd1
line update id Ln1
line update delay 82
line update loss -30
line update ul 0could you please hint here, as I have an issue with xmlParse function:
> 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’)”could you please help understand why I can`t fetch sub-child classes? I appreciate your help.
- AuthorPosts
- You must be logged in to reply to this topic.