ExpressionML (.xml)

MIME type: text/xml
Mathematica ExpressionML format.
Represents an arbitrary Mathematica expression as XML.
Used for the exchange of general expressions between Mathematica and other applications.
Plain text file, normally encoded as UTF-8.
Developed in 2002 by Wolfram Research.

Import and ExportImport and Export

  • Import["file.xml"] imports an ExpressionML file and returns an expression.
  • Export["file.xml", expr, "ExpressionML"] exports an arbitrary expression to XML.
  • Import["file.xml"] reads an XML file that holds ExpressionML data and converts it to the corresponding Mathematica expression.
  • When reading XML, Import automatically recognizes the ExpressionML format. Generic XML content will be imported as an XMLObject expression.
  • Export["file.xml", expr, "ExpressionML"] converts an arbitrary Mathematica expression to the corresponding ExpressionML data structure and writes it to an XML file.
  • Export["file.xml", XMLObject[...]] converts a symbolic XML expression to generic XML.
  • Import["file.xml", elem] imports the specified element from an ExpressionML file.
  • Import["file.xml", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "ExpressionML"] or Import["file", {"ExpressionML", elem, ...}].
  • Export["file.xml", expr, elem] creates an ExpressionML file by treating expr as specifying element elem.
  • Export["file.xml", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.xml", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.xml", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • The export format can be explicitly specified in the form Export["file", expr, "ExpressionML"] or Export["file", expr, {"ExpressionML", elems}].
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the ExpressionML format.


  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Data representation elements:
  • "Boxes"ExpressionML typeset as a Mathematica box expression
    "Expression"arbitrary Mathematica expression
    "HeldExpression"unevaluated expression
    "XMLObject"ExpressionML as a symbolic XML expression
    "XMLElement"nested XMLElement objects
  • Import and Export use the element by default.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

Convert a mathematical expression to the ExpressionML format:

Click for copyable input

Import automatically recognizes the ExpressionML format when reading XML data:

Click for copyable input

Show the available Import elements:

Click for copyable input

Convert ExpressionML to an evaluated expression:

Click for copyable input

Import without evaluating:

Click for copyable input

Convert ExpressionML to a Mathematica typesetting expression:

Click for copyable input

Import ExpressionML to a complete symbolic XML expression:

Click for copyable input

Import ExpressionML to a symbolic XML fragment:

Click for copyable input
New in 4.2 | Last modified in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »