How to get XML parser to recognize entities (eg. —)

From: Kalessin (try_at_http://jesus.com.au/html/email/kalessin)
Date: 12/17/03


Date: Wed, 17 Dec 2003 11:16:43 GMT

I'm using PHP's XML parser to validate user-entered XHTML fragments (I
wrap them in a top-level element and send them through the parser). It
works a treat, except for handling entities:

— -- is fine, but
— -- throws an error, e.g:

          "XML error: undefined entity at line 11, char 415"

(Making an entity handler didn't help, at it fails at the parsing stage.)

Obviously I could search and replace to turn entities into their
character values, but that's pretty ugly. How can I get the XML parser
to recognize XHTML's entity set? Do I need to wrap the text fragment in
a full-blown XHTML document, including the DTD specifier?

Thanks in advance,
Kalessin.