Sunday, 15 August 2010

Replace tag with dom in php -



Replace <table> tag with dom in php -

i trace al tag , replace [table]. may know how can via html parser in php?

for example:

hello there <table><tr><td>some text</td></tr></table> text <table><tr><td>some text</td></tr></table> text <table><tr><td>some text</td></tr></table>

to:

hello there [table] text [table] text [table]

may know how can removechild replace table tag , replacechild?

thanks.

view.html

hello there <table><tr><td>some text</td></tr></table> text <table><tr><td>some text</td></tr></table> text <table><tr><td>some text</td></tr></table>

parse.php

<?php // example: load view (html) string $html = file_get_contents("view.html"); while(strpos($html, "<table>") !== false) { $start = strstr($html, '<table>', true); $end = substr(strstr($html, '</table>'), 8); $html = $start ."[table]" . $end; } echo $html;

output

hello there [table] text [table] text [table]

php dom removechild

No comments:

Post a Comment