RE: [PHP] DOMDocument and html doctype
Hi, I've used loadHTML() to read a HTML file to DOM. This file starts with a string like !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN Do someone know how I can access this string? By reading the doctype back from DOMDocument I only found the name (HTML) but nothing more... Use $document-doctype, its DOMDocumentType object.. http://php.net/dom#dom.class.domdocumenttype Jared -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument and html doctype
On Sat, 2005-05-14 at 06:00, Claudio wrote: Hi, I've used loadHTML() to read a HTML file to DOM. This file starts with a string like !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN Do someone know how I can access this string? By reading the doctype back from DOMDocument I only found the name (HTML) but nothing more... ?php $html = EOS !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlbodyTestbr/body/html EOS; $pattern = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN'; $doc = new DOMDocument(); $doc-loadHTML($html); preg_match($pattern, $doc-saveHTML(), $matches); echo 'lt;' . $matches[0] . 'gt;'; ? -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DOMDocument and html doctype
On Sat, 2005-05-14 at 07:57, Jared Williams wrote: Hi, I've used loadHTML() to read a HTML file to DOM. This file starts with a string like !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN Do someone know how I can access this string? By reading the doctype back from DOMDocument I only found the name (HTML) but nothing more... Use $document-doctype, its DOMDocumentType object.. That's part of DOM XML isn't it? I think he's referring to the newer DOM extension since 'loadHTML() is cited...??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DOMDocument and html doctype
On Sat, 2005-05-14 at 07:57, Jared Williams wrote: Hi, I've used loadHTML() to read a HTML file to DOM. This file starts with a string like !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN Do someone know how I can access this string? By reading the doctype back from DOMDocument I only found the name (HTML) but nothing more... Use $document-doctype, its DOMDocumentType object.. That's part of DOM XML isn't it? I think he's referring to the newer DOM extension since 'loadHTML() is cited...??? I was referring to the new PHP5 DOM extension. Jared -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument and html doctype
On Saturday 14 May 2005 16:25, Brian V Bonini wrote: ?php $html = EOS !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlbodyTestbr/body/html EOS; $pattern = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN'; $doc = new DOMDocument(); $doc-loadHTML($html); preg_match($pattern, $doc-saveHTML(), $matches); echo 'lt;' . $matches[0] . 'gt;'; ? Well, that ist a very crazy idea... If Claudio knows the doctype allready, he not needs to access this doc type string. A preg_match is the wrong function at this place or will you write a switch/case block that knows every doctype definition? This only is usefull to see if the string exists or not. Regards -- Johannes Findeisen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument and html doctype
On Sat, 2005-05-14 at 16:08, Johannes Findeisen wrote: On Saturday 14 May 2005 16:25, Brian V Bonini wrote: ?php $html = EOS !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlbodyTestbr/body/html EOS; $pattern = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN'; $doc = new DOMDocument(); $doc-loadHTML($html); preg_match($pattern, $doc-saveHTML(), $matches); echo 'lt;' . $matches[0] . 'gt;'; ? Well, that ist a very crazy idea... If Claudio knows the doctype allready, he not needs to access this doc type string. A preg_match is the wrong function at this place or will you write a switch/case block that knows every doctype definition? This only is usefull to see if the string exists or not. I'm sorry, I missed your solution, what was it again? He said Do someone know how I can access this string? There it is, THAT string is now in $matches[0]; Do what you want with it from there. Otherwise set pattern to a regex and search for similar strings if the search pattern is not EXACTLY that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] DOMDocument and html doctype
On Sat, 2005-05-14 at 13:03, Jared Williams wrote: On Sat, 2005-05-14 at 07:57, Jared Williams wrote: Hi, I've used loadHTML() to read a HTML file to DOM. This file starts with a string like !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN Do someone know how I can access this string? By reading the doctype back from DOMDocument I only found the name (HTML) but nothing more... Use $document-doctype, its DOMDocumentType object.. That's part of DOM XML isn't it? I think he's referring to the newer DOM extension since 'loadHTML() is cited...??? I was referring to the new PHP5 DOM extension. OOppps, there it is, tabel 3 on the first page of the DOM section in the manual... I swear it wasn't there earlier.. ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php