php - Call to undefined method DOMDocument::createDocumentType() -


i have following script snippet. did not realize use getelementbyid needed include createdocumenttype, error listed above. doing wrong here? in advance!

... $result = curl_exec($ch); //contains webpage grabbing remotely  $dom = new domdocument(); $dom->createdocumenttype('html', '-//w3c//dtd html 4.01 transitional//en', 'http://www.w3.org/tr/html4/loose.dtd'); $elements = $dom->loadhtml($result); $e = $elements->getelementbyid('1'); ... 

edit: additional note, verified dom correct on remote page.

domdocument not have method named createdocumenttype, can see in manual. method belongs domimplemetation class. used (taken manual):

// creates instance of domimplementation class $imp = new domimplementation;  // creates domdocumenttype instance $dtd = $imp->createdocumenttype('graph', '', 'graph.dtd');  // creates domdocument instance $dom = $imp->createdocument("", "", $dtd); 

since want load html document, don't need specify document type, since determined imported html. have have id attributes, or dtd identifies other attribute id. part of html file, not parsing php code.

$dom = new domdocument(); $dom->loadhtml($result); $element = $dom->getelementbyid('my_id'); 

will job.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -