What libraries will parse DTD with PHP

I need to parse DTDs using PHP, and I hope there will be a simple library to help. Each DTD has many elements <!ENTITY...and <!-- Comment...which I must act on.

Please note that I do not need to check anything against these DTDs, just parse them as data files.

A few options that I looked at:

James Clarke SD , which is an option of last resort, but I would like to avoid the complexity of creating / installing / configuring code external to PHP. I am not sure if this is possible in my situation.

PEAR has an XML_DTD_Parser , which requires installing / configuring PEAR and a number of pear modules, which I am also not sure about, and would rather avoid. Has anyone used it successfully? The EDIT: . Since then, I found out that XML_DTD_Parser discards comments, therefore it is not suitable for my needs.

PHP XML Classes has a path_parser class that another site proposed, but it could not read ENTITY elements. It looks like it uses PHP built in XML parsing capabilities that use EXPAT.

PHP DOMDocument will check DTDs , so it should be able to read them, although I don’t see how to get to DTD directly at first glance.

+3
2

XML PHP *, . PHP, XML Parser Expat, API- expat; , . PHP-.

AFAICT, DTD , ; , , php (, PHP_LexerGenerator PHP_ParserGenerator .).

* PHP expat wrapper (XML Parser) , , .

+2

, ...

, , "" DTD, . . , :

, , .

+1

Source: https://habr.com/ru/post/1747285/


All Articles