I have an XML Document file. The part of the file looks like this:
-<attr>
<attrlabl>COUNTY</attrlabl>
<attrdef>County abbreviation</attrdef>
<attrtype>Text</attrtype>
<attwidth>1</attwidth>
<atnumdec>0</atnumdec>
-<attrdomv>
-<edom>
<edomv>C</edomv>
<edomvd>Clackamas County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>M</edomv>
<edomvd>Multnomah County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>W</edomv>
<edomvd>Washington County</edomvd>
<edomvds/>
</edom>
</attrdomv>
</attr>
From this XML file, I want to create an R data frame with the columns of attrlabl
, attrdef
, attrtype
, and attrdomv
. Please note that the attrdomv
column should include all of the levels for the category variable. The data frame should look like this:
attrlabl attrdef attrtype attrdomv
COUNTY County abbreviation Text C Clackamas County; M Multnomah County; W Washington County
I have an incomplete code like this:
doc <- xmlParse("taxlots.shp.xml")
dataDictionary <- xmlToDataFrame(getNodeSet(doc,"//attrlabl"))
Could you please complete my R code? I appreciate any help!