65
XML Compliance
One issue with XML is that documents must be well formed, following the rules of XML. Some basic examples of
compliance are described in this section.
An XML document must include a header. For example, it must start with something like the following.
Empty elements must either have an end tag, or the start tag must end with />. Thus, the following is legal.
However, this is not legal.
For non empty tags the end tag is required. Thus the following is legal.
Here is a paragraph.
Here is another.
However, this is not legal.
Here is a paragraph.
Here is another.
5.1.2 Mathematica Support for XML
This section gives a very brief introduction to the Mathematica tools for working with XML; more information is
available in the online documentation. One important point is that XML is suitable for holding structured data,
which also applies to Mathematica expressions (the basic data type of Mathematica). This makes it easy to import
XML data into Mathematica.
The following is a simple example.
In[7]:=
xml =
" version=\"1.0\"?>\n
\n
\n
<
title>A New Kind of ScienceWolfram Stephen
author>\n
\n
\n
The Lord of the Rings
title>J.R.R. Tolkien\n
\n ";
This XML can be imported into Mathematica, which represents it with Symbolic XML. Because of the nature of
Mathematica expressions, Symbolic XML is a Mathematica native form of XML that is isomorphic to textual XML.
.