This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Add-ons & Links / XML Capabilities / Importing XML /


The XMLGet function can be used to import an XML document as SymbolicXML. It is very similar to the Import function, in that XMLGet[file] is equivalent to Import[file, "SymbolicXML"]. The advantage of using XMLGet is that, unlike Import, it can retrieve files over the web. Hence, it is useful if you want to import an XML file posted at a URL.

For example, the following command retrieves stock quotes from a website and returns the data as SymbolicXML.



Note that XMLGet exists only in the XML`Parser` context. Hence, you must use the full name of the function, XML`Parser`XMLGet, when doing an evaluation. To use the function without the context name prefix, you must first add the XML`Parser` context to your context path.

XMLGet also accepts an optional second argument, which specifies a pre-initialized parser object.

    XMLGet[file, XMLParserObject]

Initializing the parser involves loading a DTD into memory either from a URL or a local file. This only needs to be done once in each kernel session. Subsequent references to the DTD are then processed much faster because the DTD has already been read and parsed. For more information on initializing the parser, see InitializeXMLParser.

You can also specify ConversionOptions for XMLGet to control the behavior of the function. The conversion options for XMLGet are the same as the ones for Import. However, the syntax for specifying conversion options is slightly different. The conversion option can be specified directly in the XMLGet function, such that

    XMLGet[file, option1 Rule value1, option1 Rule value2,...]

is equivalent to

    Import[file, "SymbolicXML", ConversionOptions Rule {option1 Rule value1, option2 Rule value2,...}]

For more information on conversion options for importing XML, see XML Import Conversion Options.