Skip to main content
2 of 4
added 978 characters in body; deleted 4 characters in body
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Does this work for you?

hexNodeData /. 
 XMLElement[a_, {}, {s_String}] :> 
  XMLElement[a, {}, ImportString[s, "List"]]

I am using ImportString[s, "List"] to convert numbers in the 5.0000e+000 form.


You commented that this works, but is slow; indeed it is, but I don't have a better method for you, only alternatives. This question's answers give some:

How do you convert a string containing a number in C scientific notation to a Mathematica number?

If your number were lower precision you could use Internal`StringToDouble but e.g. Internal`StringToDouble["3.141592653589793e+000"] gives $Failed["Bignum"]. Using ToExpression can be dangerous, because as Szabolcs states:

Whenever you use ToExpression on data read from a file, you make it possible to inject code into a program even inadvertently (one can never tell what sort of erroneous input the program might get by mistake).

Nevertheless it should be faster, so I present a method using it if you choose to risk it:

Block[{e},
 hexNodeData /. 
   XMLElement[a_, {}, {s_String}] :> 
    XMLElement[a, {}, {ToExpression @ s}]
      /. {e x_ + b_ :> x*10^b, e x_ :> x}
]
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k