#138 newline and outertext

v1.0_(example)
open
nobody
None
1
2014-05-28
2014-04-30
Kelloy
No

Hello folks !
I'm happy with PHSimple HTML DOM Parser, and really enjoy it !

But i have a little problem :
I want to change/remove some values from a file, so i use your tool this way :

$newFileContent = str_replace($element->outertext,"",$file->getContent());

In my $file->getContent(), there is the code of my file, that i got with file_get_contents() previously.

The problem is that the part of the $element in $file->getContent() does not match the one in $element->outertext

I hope you get what i mean,
Sorry for my bad english,
Have a nice day =),
Kelloy

Discussion

  • Kelloy
    Kelloy
    2014-04-30

    Solved with the $stripRN variable, thought is there a better way to do that ? Cause i think it will be buggy this way, don't you think ?

     
  • hlcb
    hlcb
    2014-05-28

    The solution is that even if you spoke through the $stripRN variable. As this problem is specific, I recommend that you create a custom function file_get_html with the variable already set to false.

    // Function similar to file_get_html but don't strip breaklines (\r\n)
    // $stripRN = false
    function file_get_html_rn($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=false, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
    {
        return file_get_html( $url, $use_include_path, $context, $offset, $maxLen, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText );
    }
    
     
    Last edit: hlcb 2014-05-28