How to speed up the XML DTD validation with PHP? -


I am validating my XML locally with a DTT file.

For this, I am doing:

$ xml = $ dms Marin '/ Xml /' $ Id '/ Conversion.xml'; $ Dtd = $ dms Marin '/ Style_files / journalpublishing.dtd'; $ Dom = new DOMDocument (); @ $ Dom- & gt; Load ($ XML); Libxml_use_internal_errors (true); If ($$ dom- & gt; Valid ()) {$ htmlDTDError = "& Lt; h2 & gt; No errors found - the checked file is valid! "; } And {$ errors = libxml_get_errors (); $ HtmlDTDError = '& Lt; H2 & gt; Errors found ('number ($ errors).') & Lt; / H2 & gt; & Lt; Ol & gt; '; Forex Currency ($ Error $ $ Error) {$ htmlDTDError. = '& Lt; Li & gt; '. $ Error- & gt; message. 'Line' $ Error- & gt; Line '& lt; / Li & gt; '; } $ HtmlDTDError = '& Lt; / Ol> '; Libxml_clear_errors (); } Libxml_use_internal_errors (wrong);

And it takes about 30sec for XML with 1600 lines.

Is this normal time? Should my opinion be very fast?

As you can see, I am using, on the server at the local level.

Any thoughts? Thank you.

EDIT: By debugging and checking execution time, I found that if my XML has 1600 lines or 150 lines, then the problem is not XML size.

and it takes about 30sec for XML with 1600 lines.

This is unusually long, and it may be due to a misconfiguration.

By checking the debugging and execution time, I noticed that this is my XML's 1600 lines or 150 lines, hence the problem is not xml size.

For a device that can provide more diagnostic here, try xmllint --valid . This will show, for example, errors for any DTD can not be recovered.

It is very likely that extra time is due to attracting resources, such as DTD, is essential for verification.

For one of your files, confirm that the URL of the DTD can be retrieved quickly by testing from the same server with the same device as curl is it a complex DTD is? Is it in other files? Specifically, make sure that it never refers to resources, which must be obtained from the web, or with host names where DNS is slow.


Comments