What options to parse a DTD using PHP

Posted by Chadwick on Stack Overflow See other posts from Stack Overflow or by Chadwick
Published on 2010-05-27T01:28:51Z Indexed on 2010/05/27 1:31 UTC
Read the original article Hit count: 371

Filed under:
|
|

I need to parse DTDs using PHP and am hoping there's a simple library to help out. Each DTD has numerous <!ENTITY... and <!-- Comment... elements, which I need to act upon.

Note that I do not need to validate anything against these DTDs, simply parse them as data files themselves.

A few options I've looked at:

James Clarke's SD, which is an option of last resort, but I'd like to avoid the complexity of building/installing/configuring code external to PHP. I'm not sure it's even possible in my situation.

PEAR has an XML_DTD_Parser, which requires installing/configuring PEAR and a number of pear modules, which I'm also not sure is possible, and would rather avoid. Has anyone used it with success?

PHP XML Classes has the class_path_parser, which another site suggested, but it fails to read ENTITY elements. It appears to be using PHP's built in XML parsing capabilities, which use EXPAT.

PHP's DOMDocument will validate against a DTD, so must be able to read them, though I don't see how to get at the DTD parser directly at first glance.

© Stack Overflow or respective owner

Related posts about php

Related posts about parse