# MathML interpreter returns failure on valid expression

I have the following expression

Interpreter["MathMLExpression"][$<mfrac><mo>&DifferentialD;</mo><mrow><mo>&DifferentialD;</mo><mi>x</\ mi></mrow></mfrac><mo> ( </mo><mrow><mo> - </mo><mn>5</mn></mrow><msup><mi>x</mi><mn>3</mn></msup><mo> - </mo><mn>5</mn><msup><mi>x</mi><mn>2</mn></msup><mo> - </mo><mn>3</mn><mi>x</mi><mo> - </mo><mn>4</mn><mo> ) </mo>$]


Which when I try to run, returns

Failure[ Message: Please enter a valid expression. Tag: Restriction failure]


But when I try it on Wolfram research's online interpreter, it returns fine. What am I doing wrong? (PS I have also tried ToExpression and HoldMathMLExpression--in Interpreter--and had no more luck)

• Your expression should definitely be in a String... is that just a copy-paste error? – b3m2a1 Jul 3 '19 at 21:48

## 1 Answer

ToExpression tries to get an Expression but what you've posted isn't valid Mathematica syntax. You want to use ImportString with "MathML" as the format. See this for more.

mathExpr = "$<mfrac><mo>&DifferentialD;</mo><mrow><mo>&DifferentialD;</mo><mi>x</mi></\ mrow></mfrac> <mo> ( </mo> <mrow><mo> - </mo><mn>5</mn></mrow><msup><mi>x</mi><mn>3</mn></msup> <mo> - </mo><mn>5</mn><msup><mi>x</mi><mn>2</mn></msup> <mo> - </mo><mn>3</mn><mi>x</mi><mo> - </mo><mn>4</mn> <mo>)</mo>$";
ImportString[mathExpr, "MathML"] // RawBoxes


• I was missing the raw boxes when I tried earlier. Thank you! – Silas K Grossberndt Jul 4 '19 at 13:28