HTML safety fix for broken imported HTML content?

Im importing HTML into my page via an XML feed. If the content has an unclosed or unopened div (see below) it completely messes up the page.

<div>Stuff</div>
<div>Stuff</div>
</div>

Or

<div>
<div>Stuff</div>
<div>Stuff</div>

I know the best solution is to work on the PHP parsing, which im currently looking at. However as a backup or incase I cant find a PHP solution, is there an HTML fix?

I tried enclosing the entire imported area as a fieldset, ul and li, and span. I hoped this would effectively close any open divs, but none of them worked. Thanks

Answers


is there an HTML fix?

No, there isn't. You need to fix the markup before adding it to the document.


Need Your Help

Java Swing JTextArea caret refuses to move to upper left corner

java swing jtextarea

Using the method below, I am trapping the VK_ENTER key event to gather the text in a default JTextArea, process it, and then empty the JTextArea. I noticed that the caret did not reset to the uppe...

Date format in sql server 2008

c# sql-server

I have date in format 2013-08-05 12:45:56. But I want to store this in format 2013-08-05 00:00:00 in database.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.