I am new to using XML within Mathematica. I've done a quick glance through the docs, but I am hopeful that someone may have a simple solution that I can modify for my own purposes.
I have an XML file and a snippet of that file looks like this:
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
<Piece NumberOfPoints="174186" NumberOfCells="963703">
<DataArray type="Float32" NumberOfComponents="3" format="ascii">
-1.000000000000000e+03 -1.000000000000000e+03 0.000000000000000e+00
-9.000000000000000e+02 -1.000000000000000e+03 0.000000000000000e+00
-8.000000000000000e+02 -1.000000000000000e+03 0.000000000000000e+00:
tons of similar data
I'd like to extract that data.
Here is what I have tried:
garb = Import[
grabElement[object_, string_] := Cases[object,
XMLElement[string, _, _], Infinity]
pts1 = grabElement[grabElement[garb, "Points"], "DataArray"] (*works fine*)
pts = pts1[[1, 3]] (*list of strings, some elements are [\Ellipses] *)
ToExpression[pts] (*failure... probably because the "e" in 1.0000000e+03 is getting parsed as an undefined symbol*)
I'm hopeful that someone who is familiar with such things has an easy answer they can share with me.