Hi guys,
I have the following codes of php. what it does was open the file myhtml.html and then puts a meta tag inside the html and then save the file.
PHP Code:$doc = new DOMDocument("1.0");
$doc->loadHTMLFile("myhtml.html");
$node = $doc->createElement("meta");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("name","description");
$newnode->setAttribute("content", "just a test descriptionzzz");
$xx = $newnode->getAttribute("content");
$doc->saveHTMLFile("myhtml.html");
but when i checked the myhtml.html file the code was like this :
which makes the meta tag i put into the file outside the html tag. how can i make it inside the head tag? anyone please.. thanks in advance.HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>this is ok with me</title> </head> <body> <div id="main-content">sample content of the edited html.</div> <span name="spsp">hello world!</span> </body> </html> <meta name="description" content="just a test descriptionzzz">


Reply With Quote

Bookmarks