Removing unwanted xml nodes

I have a bunch of XML files with nodes that cause unexplained complications. I would like to delete these nodes, but to ensure that their children are saved (not hierarchical structure, but data). In the end, I want to take data from each .xml and build a DataFrame. It looks like xmlTreeParse along with xmlToList will help, but the latter works well with a flat structure. I played with disabling the output from xmlToList and then converted it to a data framework, but the result is a bit funky.

I thought about just writing a function to view all the files and remove all the tags that I don’t need, but I don’t know how to do this in R.

Any suggestions?

+3
source share
2

XSLT. :

<xsl:template match="poop">
   <xsl:apply-templates select="node()"/>
</xsl:template>

XML .

+3

, , XML CRAN XML-. , <poop>:

me<-xmlTreeParse(filename,useInternalNodes=T)
pooptags<-xpathApply(me,"//poop")

pooptags :

<poop>
  <P3a_Village1>dzemeni</P3a_Village1>
  <P4_HousholdNumber/>
  <P5_VisitNumber>2</P5_VisitNumber>
</poop> 

<?xml version='1.0' ?> R . , ​​ P3a_Village1, XML, xpathApply, :

village<-xpathApply(me,"//poop/P3a_Village1")

, - , . , , .

0

Source: https://habr.com/ru/post/1751969/


All Articles