The following piece of code outputs a parsed html:
$domd = new DOMDocument('5.0', 'utf-8');
libxml_use_internal_errors(true);
$domd->loadHTML(mb_convert_encoding(($postDetails['content']), 'HTML-ENTITIES', 'UTF-8'));
libxml_clear_errors();
echo $domd->saveHTML();
However it, outputs extra tags like <html>
, <head>
, etc. I want to only get the content inside the body
tag. How do I achieve that?
For eg: if the <body>
tag contains <p>
or other tags that may contain content, I need to display those as it is.