dave1 Posted October 1, 2009 Share Posted October 1, 2009 I assumed that this property would be null if no doctype exists, instead it's never null. If no doctype is present, it will still return a DOMDocumentType object that is: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> example: $dom = new DomDocument(); $dom->loadHTML($html); $doctype = $dom->doctype; echo $doctype->internalSubset; Anyone know what's going on, or an alternate way I can parse the html and extract the doctype? Can this be done with DOMXPath? Thanks. Link to comment https://forums.phpfreaks.com/topic/176149-problem-with-domdocument-domdocumenttype/ Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 what is this all about please can you explain really slowly so i understand all what going on. currently it like a scientific project needing a professor. Link to comment https://forums.phpfreaks.com/topic/176149-problem-with-domdocument-domdocumenttype/#findComment-928262 Share on other sites More sharing options...
salathe Posted October 1, 2009 Share Posted October 1, 2009 As you can see, when using DOMDocument::loadHTML with no doctype present then it will automatically add the HTML 4.0 Transitional doctype to the document. As far as I'm aware, there is no flag to turn this behaviour off. If you want to find out the presence of a doctype then it might mean manually inspecting the source HTML (doctypes need to be at the beginning of the source so it's not too difficult). Link to comment https://forums.phpfreaks.com/topic/176149-problem-with-domdocument-domdocumenttype/#findComment-928347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.