php - DOMDocument: how to append after <title> tag -


i have following code , works far.

however, try attach <link href=".." ../> tag below <title> tag or, better yet, below last <meta> tag.

is there way accomplish domdocument?

$dom = new domdocument(); $dom->loadhtml($html_data);  $element = $dom->createelement( 'link'); $element->setattribute( 'rel', 'stylesheet' ); $element->setattribute( 'type', 'text/css' ); $element->setattribute( 'href', $url ); $element->setattribute( 'media', isset($media) ? $media : 'screen' );  $head = $dom->getelementsbytagname('head')->item(0); $head->appendchild($element); echo $dom->savehtml();   


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -