My code for parsing MathML to be readable in Mathematica:
ToExpression @ ImportString @ ExportString[#, "XML"]& /@ Cases[
xml, XMLElement["math", _, _],∞
]
The MathML contents:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<ci> MM_e</ci>
<ci> mem </ci>
<ci> k </ci>
<ci> sp_3 </ci>
<ci> sp_1 </ci>
<ci> Km </ci>
</apply>
</math>
I am getting this error when extracting MathML from a XML file. :
ToExpression::esntx: Could not parse FormBox[TagBox[RowBox[{MM_e,RowBox[{(,RowBox[{<<9>>}],)}]}],MathMLContentTag,AutoDelete->True],TraditionalForm] as input.
The math should display like this:
MM_e(mem,k,sp_3,sp_1,Km)
But it only displays somewhat correctly when I copy MathML content to Mathematica which then asks
"Do you want to paste the typeset expression?"
MM_e(mem,k,3 sp_,1 sp_,Km)
Although when using DisplayForm
there are no errors but with other math content, it does not simplify unless I use Shift+Enter on the output.
DisplayForm @ ImportString @ ExportString[#, "XML"] & /@ Cases[
xml, XMLElement["math", _, _], ∞
]
How can I fix this error without using DisplayForm
?
DisplayForm
ok? You can replace it withRawBoxes
but that does not change much. $\endgroup$MM_e(mem,k,3 sp_,1 sp_,Km)
which is not a valid Mathematica syntax? $\endgroup$