ExpressionML (.xml)
Background & Context

-
- MIME type: text/xmlWolfram Language ExpressionML format.
- Represents an arbitrary Wolfram Language expression as XML.
- Used for the exchange of general expressions between the Wolfram System and other applications.
- Plain text file, normally encoded as UTF-8.
- Developed in 2002 by Wolfram Research.
Import & 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 Wolfram Language 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 Wolfram Language 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 expri as specifying the corresponding elemi.
- 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 following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements

- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"Boxes" ExpressionML typeset as a Wolfram Language box expression "Expression" arbitrary Wolfram Language expression "HeldExpression" unevaluated expression "XMLObject" ExpressionML as a symbolic XML expression "XMLElement" nested XMLElement objects - Import and Export use the "Expression" element by default.
Examples
Basic Examples (1)Summary of the most common use cases
Convert a mathematical expression to the ExpressionML format:
In[1]:=1

✖
https://wolfram.com/xid/0b3t1s6inc-ix6szx
Out[1]=1

Import automatically recognizes the ExpressionML format when reading XML data:
In[2]:=2

✖
https://wolfram.com/xid/0b3t1s6inc-r2wx5u
Out[2]=2

Show the available Import elements:
In[3]:=3

✖
https://wolfram.com/xid/0b3t1s6inc-jt826b
Out[3]=3

Convert ExpressionML to an evaluated expression:
In[4]:=4

✖
https://wolfram.com/xid/0b3t1s6inc-ug6eym
Out[4]=4

In[5]:=5

✖
https://wolfram.com/xid/0b3t1s6inc-1ab8cc
Out[5]=5

Convert ExpressionML to a Wolfram Language typesetting expression:
In[6]:=6

✖
https://wolfram.com/xid/0b3t1s6inc-fofrb5
Out[6]=6

Import ExpressionML to a complete symbolic XML expression:
In[7]:=7

✖
https://wolfram.com/xid/0b3t1s6inc-4vkooh
Out[7]=7

Import ExpressionML to a symbolic XML fragment:
In[8]:=8

✖
https://wolfram.com/xid/0b3t1s6inc-lceikd
Out[8]=8
