0

Using

    $html = '<br /><p>k</p>';
libxml_use_internal_errors(true);
$dom = New DOMDocument();
$dom -> loadXML($correo_elhtml);
echo '<pre>';
if(empty(libxml_get_errors())){
    echo "This is a good HTML";
    }
else {
    echo "This not html";
    print_r(libxml_get_errors());
    }

return ERROR, however that is a valid XHTML STRING.

Some function please?

1
  • Well-formed XML has a single root node. Commented Apr 10, 2021 at 2:48

1 Answer 1

1

This code is a correct HTML but is NOT correct as XML, because empty-element tag, such as <br /> in XML must used only between <section></section>

So you can use $dom -> loadHTML($html); or remove <be /> from your HTML and then use $dom -> loadXML($html);

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks masters @Alohci and @Ehsan. Then a practice infalible to test ANY string is: $dom -> loadXML('<div>'.$html.'</div>'); ?
@Stackoverflow please mark my response as your question answer
Master @Ehsan I doit many hours back: https://pasteboard.co/JWSM6l1.png
oh god! by first time I see this option. SORRY. Just I put in this option now. Many thanks by your lesson #2 :-)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.