I'm wanting to convert the following xml document into a dataframe I can use to access the coordinate information.
a3 <- xmlParse("test.xml")
I figured I will have to do some kind of apply function, but I'm still not certain how to handle xml subnodes with many subnodes that are used to identify that particular node. <Marker_Data>
and <Marker>
nodes use a subnode and sister node (respectively) for their unique identification. Is this a straightforward problem? The examples I've seen on stack overflow have unique xml attributes at each level to identify the node: example - Parsing XML with different number of subnode with same name in R or Extract second attribute of a xml node in R (XML package)
I would like to make a dataframe like this:
| Filename | Type| Xaxis| Yaxis | Zaxis |
| File.tif | 1 | 7172 | 4332 | 1 |
| File.tif | 1 | 7170 | 4140 | 1 |
| File.tif | 2 | 6172 | 4332 | 1 |
| File.tif | 2 | 5173 | 4140 | 1 |
test.XML:
<?xml version="1.0" encoding="UTF-8"?>
<CellCounter_Marker_File>
<Image_Properties>
<Image_Filename>File.tif</Image_Filename>
</Image_Properties>
<Marker_Data>
<Marker_Type>
<Type>1</Type>
<Marker>
<MarkerX>7172</MarkerX>
<MarkerY>4332</MarkerY>
<MarkerZ>1</MarkerZ>
</Marker>
<Marker>
<MarkerX>7170</MarkerX>
<MarkerY>4140</MarkerY>
<MarkerZ>1</MarkerZ>
</Marker>
</Marker_Type>
<Marker_Type>
<Type>2</Type>
<Marker>
<MarkerX>6172</MarkerX>
<MarkerY>4332</MarkerY>
<MarkerZ>1</MarkerZ>
</Marker>
<Marker>
<MarkerX>5173</MarkerX>
<MarkerY>4140</MarkerY>
<MarkerZ>1</MarkerZ>
</Marker>
</Marker_Type>
</Marker_Data>
</CellCounter_Marker_File>