I've got a case where I'm trying to parse a hunk of HTML that contains <br>
tags -- that is, not <br />
. simplexml_load_string handles <br />
correctly, but throws warnings (and fails to return a parse) with <br>
:
simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: br line 1 and div [warning]
simplexml_load_string(): <div class='dummy_root'><div>Basic text.<br> More text.</div></div>
I'm not the one putting the <br>
's into the text, so I have to find a way to deal with it. I could of course write some sort of preprocessing / cleanup / text munghing code to replace the <br>
s with <br />
s, but I thought I'd check to see if there is something "better" to do here. Any thoughts? Thanks!
What you could do is replace/remove the <br>
tag like so:
simplexml_load_string(str_replace("<br>", "", $string));