Exchanging Material with the Web

Converting notebooks to HTML.

(RefLink[Export, paclet:ref/Export]) has many options applying to HTML export that allow you to specify how notebooks should be converted for web browsers with different capabilities.

Converting to and from MathML.

Here is an expression printed in MathML form:

MathMLForm[x^2/z]

If you paste MathML into a Wolfram System notebook, the Wolfram System will automatically try to convert it to Wolfram Language input. You can copy an expression from a notebook as MathML using the (MenuGrayLink[Copy As, paclet:ref/menuitem/CopyAs]) menu in the notebook front end.

XML importing and exporting.

Somewhat like Wolfram Language expressions, XML is a general format for representing data. The Wolfram Language automatically converts certain types of expressions to and from specific types of XML. MathML is one example. Another example is SVG for graphics.

If you ask the Wolfram Language to import a generic piece of XML, it will produce a SymbolicXML expression. Each XML element of the form <elem attr='val'>data</elem> is translated to a Wolfram Language SymbolicXML expression of the form (RefLink[XMLElement, paclet:ref/XMLElement])["elem",{"attr"->"val"},{data}]. Once you have imported a piece of XML as SymbolicXML, you can use the Wolfram Language's powerful symbolic programming capabilities to manipulate the expression you get. You can then use (RefLink[Export, paclet:ref/Export]) to export the result in XML form.

This generates a SymbolicXML expression, with an (RefLink[XMLElement, paclet:ref/XMLElement]) representing the a element in the XML string:

ImportString["<a aa='va'>s</a>","XML"]

There are now two nested levels in the SymbolicXML:

ImportString["<a><b bb='1'>ss</b><b bb='2'>ss</b></a>","XML"]

This does a simple transformation on the SymbolicXML:

%/."ss"->XMLElement["c",{},{"xx"}]

This shows the result as an XML string:

ExportString[%,"XML"]

Importing data from web sources.

This imports a picture from a website:

Import["http://reference.wolfram.com/mathematica/ExampleData/ocelot.jpg"]