|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
[js] HTML to XHTML
Hello,
I'm currently building a HTML to XHTML parser in JavaScript. I've made a function toArray(); to explode an input string. (ie <b>test</b> becomes array('<b>', 'test', '</b>')); That function also corrects the HTML following the XHTML standard. The toArray() function returns an Array. That Array is fully XHTML compatible, execpt the nesting part. Does anyone know of the existance of an algorithm that corrects the nesting of tags? |
|
#2
|
|||
|
|||
|
RE: [js] HTML to XHTML
uhh.. that is not that simple.
html parsers are very hard to do, since html is really sgml, which is a big brother of xml. xml (and xhtml) was invented to be easier to parse, even if it less capable than sgml. so, no, i don't think it can easily be done with js. now, if you are willing to do it on the server side (php?), there is html tidy program that parses "html tag soup" ;) (and/or converts it to xhtml) http://tidy.sourceforge.net/ even better thing is that libtidy will soon be an extension to php, so, we will be able to do all sorts of neat stuff with it |
|
#3
|
|||
|
|||
|
RE: [js] HTML to XHTML
Well,
I finally managed to create a working parser. This parser converts HTML into XHTML. It's 95% safe and now I'm going to add some new things that are not compatible now. (ie: and IMG tag must have an alt attribute, enz) I prefer a JS version, since some CMS Wysiwyg editors need XHTML support. Those editors are often made compatible for several programming languages like PHP, ASP, CF, Perl... So, a JS parser is a perfect solution. My parser parser a 120kb file (2100 lines of code) in 1.6 sec. |
|
#4
|
|||
|
|||
|
RE: [js] HTML to XHTML
are you willing to share that code? ;)
|
|
#5
|
|||
|
|||
|
RE: [js] HTML to XHTML
Actually I'm not,
Good HTML to XHTML parsers are hard to find and I've spend lots of hours performance tuning. I'm going to sell the script to several CMS companies. I already have a customer (yoehoe)... My script reduced the number of errors on www.devarticles.com from 492 to 16... That's 97% reducing... So, unfortunately I'm not going the share this stuff |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > [js] HTML to XHTML |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|