PHP - Transform HTML to valid XHTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

Do you know what XHTML is?

Yes
6
75%
No
2
25%
XHTML? You mean HTML don't you?
0
No votes
 
Total votes: 8

phpante
Forum Newbie
Posts: 1
Joined: Mon Nov 11, 2002 7:08 am

PHP - Transform HTML to valid XHTML

Post by phpante »

Does anybody have a script that takes a string of HTML as input and transforms the string and outputs a string containing valid XHTML.

I have an WYSIWYG-editor that produce code as

Code: Select all

<FONT COLOR=#FF0000>hello!</FONT>
but I want to transform the code to be valid XHTML i.e

Code: Select all

<font color="#FF0000">hello!</font>
.

Anybody got any idea?



Thanks,
Andreas :D
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Which editor are you using, Dreamweaver can be set so that it overrides the case of the attributes in the HTML. As for scripts, have you checked hotscripts.com?

On a side note, the <font> tag is deprecated in XHTML - you should be using CSS instead if you want your code to validate.

Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://www.w3.org/People/Raggett/tidy/
HTML tidy can (amongst other features) transform most html-documents into valid xhtml.
Post Reply