# Export to presentation or content MathML: export_mathml

### 2.7.7 Export to presentation or content MathML: export_mathml

You can translate the result of an expression into various types of MathML with the export_mathml command.

- export_mathml takes one mandatory argument and one optional argument:
  - expr, an expression.
  - Optionally, format, which can be content or display, specifying what output format should be used.
- export_mathml(expr ⟨ ,format⟩) returns the result of evaluating expr written in MathML, with a single math block which will be a semantics block.
  - With no second argument, the semantics block will contain both presentation and content MathML.
  - With a second argument of content, the semantics block will only contain the content MathML.
  - With a second argument of display, the semantics block will only contain the presentation MathML.

#### Examples.

- Input:
  xml_print(export_mathml(a+2*b))
  Output:

  `<math xmlns='http://www.w3.org/1998/Math/MathML'>`
  `<semantics>`
  `<mrow xref='id5'>`
  `<mi xref='id1'>a</mi>`
  `<mo>+</mo>`
  `<mrow xref='id4'>`
  `<mn xref='id2'>2</mn>`
  `<mo>&it;</mo>`
  `<mi xref='id3'>b</mi>`
  `</mrow>`
  `</mrow>`
  `<annotation-xml encoding='MathML-Content'>`
  `<apply id='id5'>`
  `<plus/>`
  `<ci id='id1'>a</ci>`
  `<apply id='id4'>`
  `<times/>`
  `<cn id='id2' type='integer'>2</cn>`
  `<ci id='id3'>b</ci>`
  `</apply>`
  `</apply>`
  `</annotation-xml>`
  `<annotation encoding='giac'>a+2*b</annotation>`
  `</semantics>`
  `</math>`

- Input:
  xml_print(export_mathml(a+2*b,content))
  Output:

  `<math xmlns='http://www.w3.org/1998/Math/MathML'>`
  `<apply id='id5'>`
  `<plus/>`
  `<ci id='id1'>a</ci>`
  `<apply id='id4'>`
  `<times/>`
  `<cn id='id2' type='integer'>2</cn>`
  `<ci id='id3'>b</ci>`
  `</apply>`
  `</apply>`
  `</math>`

- Input:
  xml_print(export_mathml(a+2*b,display))
  Output:

  `<math xmlns='http://www.w3.org/1998/Math/MathML'>`
  `<mrow>`
  `<mi>a</mi>`
  `<mo>+</mo>`
  `<mrow>`
  `<mn>2</mn>`
  `<mo>&it;</mo>`
  `<mi>b</mi>`
  `</mrow>`
  `</mrow>`
  `</math>`

- Input:

  s:=export_mathml(1/(x^2+1),display):;
  xml_print(s)

  Output:

  `<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'>`
  `<mfrac>`
  `<mn>1</mn>`
  `<mrow>`
  `<msup>`
  `<mi>x</mi>`
  `<mn>2</mn>`
  `</msup>`
  `<mo>+</mo>`
  `<mn>1</mn>`
  `</mrow>`
  `</mfrac>`
  `</math>`