SHARE
TWEET

Test remove empty HTML tags

Manhhailua Jan 10th, 2014 61 Never
  1. $demo = '<div><span><span><span></span></span></span></div><div><span></span>manhhailua</div>';
  2.  
  3. $oDOMHTML = DOMDocument::loadHTML(
  4.     $demo,
  5.     LIBXML_HTML_NOIMPLIED |
  6.     LIBXML_HTML_NODEFDTD |
  7.     LIBXML_NOBLANKS |
  8.     LIBXML_NOEMPTYTAG
  9. );
  10.  
  11. $sYourHTMLStringWithoutEmptyTags = $oDOMHTML->saveXML();
  12.  
  13. echo $sYourHTMLStringWithoutEmptyTags;
RAW Paste Data
Top