0

I am just starting with Simple PHP HTML DOM PARSER so, what is the way to replace text only of any fetched content. Suppose i have fetched some content from a website with full HTML codes, but while applying PHP code like $html = str_replace(".", "DOT", $html); it cause a error. Because in this case it replace all . with DOT so that all links are broken, but what i want is just to replace . to DOT in texts but all code should be untouched.
Assuming, The fetched data is something like this
<a href="http://example.com">Example.com</a>
The Output should be like this
<a href="http://example.com">ExampleDOTcom</a>
how to do like this? I'm a beginner so please describe more ... sorry for the damn question :)

2
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by rakibtg
0

If you use a DOM parser, then you should loop through all nodes, replacing only the dot in the value texts.

0

so what i should do if i need to replace something else .. may you have any example ..

0

something like this:

    <?php
    include("dom.php");
    $html = file_get_html("http://www.ssssssssss.com/");
    $result = $html->find('ol', 0);
    $nav_bar = $html->find('div[id=navbar]', 0);
    $result = str_replace($nav_bar, '', $result);
    echo $result;
    ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.