Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
173
rated 0 times [  180] [ 7]  / answers: 1 / hits: 34985  / 14 Years ago, thu, june 17, 2010, 12:00:00

Whenever we are fetching some user inputed content with some editing from the database or similar sources, we might retrieve the portion which only contains the opening tag but no closing.


This can hamper the website's current layout.


Is there a clientside or serverside way of fixing this?


More From » php

 Answers
4

Found a great answer for this one:



Use PHP 5 and use the loadHTML() method of the DOMDocument object. This auto parses badly formed HTML and a subsequent call to saveXML() will output the valid HTML. The DOM functions can be found here:



http://www.php.net/dom



The usage of this:



$doc = new DOMDocument();
$doc->loadHTML($yourText);
$yourText = $doc->saveHTML();

[#96467] Monday, June 14, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
casandra

Total Points: 334
Total Questions: 93
Total Answers: 104

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;