Message Boards Message Boards

[?] Convert from MAthML code?

I am interested to learn that is the best way to convert a formula of a text found in math class of a MathML code . This is usually the format used when publishing a formula in the web. Here is a example of the code for

(\!\(TraditionalForm\`\*
SubscriptBox[r, "\[UpTee]"] \*= \*
SubscriptBox[n, "1"] \*cos \*
SubscriptBox[\[Theta], "1"] \*
SubscriptBox[\[Minus]n, "2"] \*cos \*
SubscriptBox[\[Theta], "2"] \*
SubscriptBox[n, "1"] \*cos \*
SubscriptBox[\[Theta], "1"] \*
SubscriptBox[+n, "2"] \*cos \*
SubscriptBox[\[Theta], "2"]\))

Here is the ML code which I will like to convert.

<math class="math" xmlns="http://www.w3.org/1998/Math/MathML">
<mtext>r</mtext>
<msub>
<mi></mi>
<mn>&#x22A5;</mn>
</msub>
<mtext>=</mtext>
<mtext>n</mtext>
<msub>
<mi></mi>
<mn>1</mn>
</msub>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>cos</mtext>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>&#x3B8;</mtext>
<msub>
<mi></mi>
<mn>1</mn>
</msub>
<mtext>&#x2212;n</mtext>
<msub>
<mi></mi>
<mn>2</mn>
</msub>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>cos</mtext>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>&#x3B8;</mtext>
<msub>
<mi></mi>
<mn>2</mn>
</msub>
<mtext>n</mtext>
<msub>
<mi></mi>
<mn>1</mn>
</msub>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>cos</mtext>
<mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
<mtext>&#x3B8;</mtext>
<msub>
<mi></mi>
<mn>1</mn>
</msub>
<mtext>+n</mtext>
<msub>
<mi></mi>
<mn>2</mn>
</msub>


    <mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
    <mtext>cos</mtext>
    <mspace sp="0.25" width="2px" linebreak="nobreak" is="true" />
    <mtext>&#x3B8;</mtext>
    <msub>
    <mi></mi>
    <mn>2</mn>
    </msub>
    </math>
POSTED BY: Jose Calderon
2 Replies

Jose,

I think this answers your question: Documentation

In summary, create some MathML:

str = ExportString[(1 + a)/b, "MathML"]

Convert it back to an Expression:

ImportString[str, "Expression"]

Regards

POSTED BY: Neil Singer

Thank you for the response. I admit that I am having a communication issue here.

First, I am having a difficult time transferring MathML test into mathematica notebook. The first block of my post is a copy paste as imported from a MathML found on a online scientific journal. The text will paste but annoying red boxes are inserted in between terms. I tried to remove the therese boxes and then the resulting new format was copy into the exchange input box. Completing this did not worked as well either. I am including my notebook here for your inspection.

Attachments:
POSTED BY: Jose Calderon
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract