title: What libraries will parse a DTD using PHP
body: <p>I need to parse DTDs using PHP and am hoping there's a <em>simple</em> library to help out. Each DTD has numerous <code>&lt;!ENTITY...</code> and <code>&lt;!-- Comment...</code> elements, which I need to act upon.</p>
  
  <p>Note that I do <em>not</em> need to validate anything against these DTDs, simply parse them as data files themselves.</p>
  
  <p>A few options I've looked at:</p>
  
  <p><a href="http://jclark.com/sp/" rel="nofollow noreferrer">James Clarke's SD</a>, 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.</p>
  
  <p>PEAR has an <a href="http://pear.php.net/package/XML_DTD/docs/latest/XML_DTD/XML_DTD_Parser.html" rel="nofollow noreferrer">XML_DTD_Parser</a>, 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? <strong>EDIT:</strong> I've since learned that XML_DTD_Parser discards comments, so is not a valid option for my needs.</p>
  
  <p><a href="http://phpxmlclasses.sourceforge.net/" rel="nofollow noreferrer">PHP XML Classes</a> 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.</p>
  
  <p>PHP's <a href="http://www.php.net/manual/en/domdocument.validate.php" rel="nofollow noreferrer">DOMDocument will validate against a DTD</a>, so must be able to read them, though I don't see how to get at the DTD parser directly at first glance.</p>