html - php DOM changes not saving -
i use php simple html dom parser open html file, change src of images , save. echo shows changes no actual src changes occur html file. here code , use xamp test code.
<?php include_once'simple_html_dom.php'; $html = file_get_html('index.html'); $dom = new domdocument; $dom->loadhtml($html); $nodes = $dom->getelementsbytagname('img'); foreach ($nodes $node) { $node->setattribute('src', 'images/jelly.png'); } $dom->save('index.html'); echo $dom->savehtml(); exit;
what cause changes not save? if says permissions set 4 options of accessing on files properties write ie: system, auth users, admin , users no luck.
please refer the documentation, should more so:
<?php include_once'simple_html_dom.php'; $html = file_get_html('index.html'); foreach ($html->find('img') $element) { $element->src = 'images/jelly.png'; } $html->save('index.html'); echo $html;
Comments
Post a Comment