Frequently Asked Questions about Expat

Where can I get the latest version of expat?

The latest production version is always available from ftp://ftp.jclark.com/pub/xml/expat.zip. If there is a test version, then it will be available from ftp://ftp.jclark.com/pub/test/expat.zip.

Where can I get help in using expat?

Try the xml-dev mailing list (subscribe by mailing to majordomo@ic.ac.uk with the message subscribe xml-dev). Alternatively try the comp.text.xml USENET newsgroup.

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.

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?

expat only reads the internal DTD subset. It doesn't process an external DTD nor parameter entity references. This behaviour is in conformance with the XML Recommendation.

Why does expat give the wrong result for the more complex example in Appendix D of the XML Recommendation?

expat does not process parameter entity references. (The XML Recommendation only requires parsers to process parameter entity references when validating. See section 4.4.8.)

Why does expat give the wrong result for test cases in James Clark's test suite in the xmltest/valid/not-sa?

expat doesn't process parameter entities.

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