Hi, I need a function/class to validate a piece of html code. Like if my html is: $h=' <P><A HREF=URL_HERE> some text </A> other normal text <FONT FACE="arial"> More Text </FONT></P> '; then that function/class would convert it to validate html For example there's no " sign in the href tag, and it's in uppercase. The entire font tag needs to be dropped and replaced with <span> may be... There could be more attributes inside the font tag, and all need to be replaced with <span> and style. Like: <FONT SIZE=4 FACE="arial"> More Text </FONT> Can anyone do this, or if there's a class/function already available, then please point me to it. Thanks
I'd advise you to have a look at the HTML tidy extension (php.net/tidy). You can find lots of good information at devzone.zend.com/node/view/id/761.
Thanks for that, but that extension may not be available on some servers. This is needed for a freely redistributable script. Anything else I can use? Thanks
Most of the tags will be: <P>, <A HREF></A>,<FONT SIZE FACE COLOR></FONT>,<IMG SRC>,<TABLE WIDTH VALIGN CELLSPACING CELLPADDING BORDER><TR><TD WIDTH VALIGN></TD></TR></TABLE>. Apart from these, BACKGROUND attribute at different places like inside <TD background=> The values of attributes can be inside "" sign, or without those. Like: <A HREF="URL"></A> OR <A HREF=URL></A>. There could be more like these in background, src etc... Thanks