Frequently Asked Questions about Expat

Where can I get the latest version of expat?

The latest version of expat 1.X is available from ftp://ftp.jclark.com/pub/xml/expat.zip. New versions of expat will be available from expat.sourceforge.net.

Where can I get help in using expat?

Try the xml-dev mailing list (subscribe by mailing to majordomo@xml.org with the message subscribe xml-dev). Alternatively try the mailing lists hosted by sourceforge.net.

Where is expat's API documented?

In xmlparse/xmlparse.h. There's also an advanced, low-level API you can use which is documented in xmltok/xmltok.h.

There's also an excellent article about expat on XML.com by Clark Cooper.

Is there a simple example of using expat's API?

See sample/elements.c

How can I get expat to deal with non-ASCII characters?

By default, expat assumes that documents are encoded in UTF-8. In UTF-8, ASCII characters are represented by a single byte as they would be in ASCII, but non-ASCII characters are represented by a sequence of two or more bytes all with the 8th bit set. The encoding most widely used for European languages is ISO 8859-1 which is not compatible with UTF-8. To use this encoding, expat must be told either by supplying an argument of "iso-8859-1" to XML_ParserCreate, or by starting the document with <?xml version="1.0" encoding="iso-8859-1"?>.

What encodings does expat support?

expat has built in support for the following encodings:

Additional encodings can be supported by using XML_SetUnknownEncodingHandler.

How can I get expat to validate my XML documents?

You can't. expat is not a validating parser.

How can I get expat to read my DTD?

Compile with -DXML_DTD and call XML_SetParamEntityParsing.

How can I get expat to recover from errors?

You can't. All well-formedness errors stop processing. Note that the XML Recommendation does not permit conforming XML processors to continue normal processing after a fatal error.

How do I get at the characters between tags?

Use XML_SetCharacterDataHandler.

How can I minimize the size of expat?

Compile with -DXML_MIN_SIZE. With Visual C++, use the Win32 MinSize configuration: this creates an xmlparse.dll that does not require xmltok.dll.

James Clark