XHTML Complient parser?

Reply

Join Date: Feb 2002
Posts: 12,019
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

XHTML Complient parser?

 
0
  #1
Feb 7th, 2003
Is there a program (such as Dreamweaver, Visual Studio.NET, etc) that will parse my HTML code and make it XHTML complient?

For example, I'd like to throw at it all of the pages of TechTalk forums and have it automatically convert, for example

HTML and CSS Syntax (Toggle Plain Text)
  1. <input type=submit name=submit value=Go>
to
HTML and CSS Syntax (Toggle Plain Text)
  1. <input type="submit" name="submit" value="Go" />
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,019
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #2
Feb 7th, 2003
I figured out that Dreamweaver MX will, indeed, do this. But it only works for XHTML 1.0, and XHTML 2.0 was just announced a lil while ago. Maybe I should wait until a Dreamweaver plugin/update is available??
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,019
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #3
Feb 7th, 2003
Nevermind, this makes no sense. When I take an HTML document and click on "convert to XHTML" all it does is add the following to the head:

HTML and CSS Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">

It doesn't make any other changes?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 898
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Solved Threads: 28
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend
 
0
  #4
Feb 8th, 2003
I don't know about converting your code to XHTML, but I know that all code in VS.NET (with reguard to ASP.NET Pages) are in XHTML format.
-Ryan Hoffman

.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 1,135
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Solved Threads: 6
Team Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor
 
0
  #5
Feb 15th, 2003
You can give XML Spy a try. Definitely an awesome program to do any XML development. I used this for a JSP shopping cart. You can give HTML Tidy a try but I'm not sure of its capabilities (have not tried it, though I hear is good). It's a free program under SourgeForge unlike XML Spy. Here are the web sites:

http://www.altova.com/products_ide.html
http://tidy.sourceforge.net/

If you need to convert to XHTML you can try this PHP function. It has some quirkiness at times. This is what I used when I was redesigning the Hofstra CSC web site for the CSC club.

HTML and CSS Syntax (Toggle Plain Text)
  1. <?
  2.  
  3. if (!empty($type)) {
  4.  
  5. if ($type == "path") {
  6. if (!empty($path)) {
  7. if (file_exists($path) && is_file($path)) {
  8. $file = file($path);
  9. if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=0;
  10. $file = join('', $file);
  11. } else {
  12. die ("No such file.");
  13. }
  14. } else {
  15. die ("No file specified.");
  16. }
  17. } elseif ($type == "file") {
  18. if (!empty($file)) {
  19.  
  20. } else {
  21. die ("No file specified.");
  22. }
  23. } else {
  24. die ("No file specified.");
  25. }
  26.  
  27. # specify html file, check for doctype
  28. //$file = file("file.html");
  29. //if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=1;
  30. //$file = join('', $file);
  31.  
  32. # make tags and properties lower case, close empty elements, quote all properties
  33. $search = array ("'(<\/?)(\w+)([^> ]*>)'e",
  34. "'(<\/?)(br|input|meta|link|img)([^> ]*)( />)'ie",
  35. "'(<\/?)(br|input|meta|link|img)([^> ]*)(/>)'ie",
  36. "'(<\/?)(br|input|meta|link|img)([^> ]*)(>)'ie",
  37. "'(\w+=)(\w+)'ie",
  38. "'(\w+=)(.+?)'ie");
  39. $replace = array ("'\\1'.strtolower('\\2').'\\3'",
  40. "'\\1\\2\\3>'",
  41. "'\\1\\2\\3>'",
  42. "'\\1\\2\\3 /\\4'",
  43. "strtolower('\\1').'\"\\2\"'",
  44. "strtolower('\\1').'\\2'");
  45. $file = preg_replace($search, $replace, $file);
  46.  
  47. # return xhtml-compliant document
  48. echo "<textarea cols=\"100\" rows=\"20\"> ";
  49. if (isset($doctype)) echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'."\n";
  50. echo stripslashes(stripslashes(stripslashes($file)));
  51. echo "</textarea> ";
  52.  
  53. } else {
  54. ?>
  55. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
  56. <head> <title> HTML -> XHTML Convertor</title> </head>
  57.  
  58. <body>
  59.  
  60. <!-- WARNING: this input method is a security risk on open servers //-->
  61. <form action="<?=$PHP_SELF?>" method="get">
  62. <input type="hidden" name="type" value="path" />
  63. <font face="verdana">File path:</font> <input type="text" name="path" size="50" />
  64. <input type="submit" value="Submit" />
  65. </form>
  66.  
  67. <b><font face="verdana">OR</font></b><br /><br />
  68.  
  69. <form action="<?=$PHP_SELF?> " method="get">
  70. <input type="hidden" name="type" value="file" />
  71. <font face="verdana"> File contents:</font> <br />
  72. <textarea name="file" rows="10" cols="50"> </textarea> <br />
  73. <input type="submit" value="Submit" />
  74. </form>
  75.  
  76. </body>
  77.  
  78. </html>
  79. <?
  80. }
  81. ?>
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,019
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb
 
0
  #6
Feb 15th, 2003
I found a Dreamweaver MX extension which does the trick perfectly. The only problem is that it automatically adds <HTML><HEAD> etc tags to the top and bottom of my code, to make it "complete".

The problem with this is that this forum uses a templating system, in which the top and bottom are shared borders. Therefore, I'd have to manually remove the top and bottom code from each page (and there are a LOT of pages)!

I'm procrastinating doing it for now. Debating whether it's worth my time or if next month I'll have a whole new design going (at which time I'll make it XHTML complient right from the start).
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 4
Reputation: linladen is an unknown quantity at this point 
Solved Threads: 0
linladen linladen is offline Offline
Newbie Poster

Open Source XHTML Generator and XHTML Parser in C

 
0
  #7
Jun 28th, 2004
Hi, The coding is fine in PHP,
But it would be fine if some co
uld provide me with the XHTML Parser and
XHTML Generator startup source code in C ? Or
Could give An Opensource XHTML Generator and XTHML Parser in C .

Thanks & Regards,
karthik


Originally Posted by inscissor
You can give XML Spy a try. Definitely an awesome program to do any XML development. I used this for a JSP shopping cart. You can give HTML Tidy a try but I'm not sure of its capabilities (have not tried it, though I hear is good). It's a free program under SourgeForge unlike XML Spy. Here are the web sites:

http://www.altova.com/products_ide.html
http://tidy.sourceforge.net/

If you need to convert to XHTML you can try this PHP function. It has some quirkiness at times. This is what I used when I was redesigning the Hofstra CSC web site for the CSC club.

HTML and CSS Syntax (Toggle Plain Text)
  1. <?
  2.  
  3. if (!empty($type)) {
  4.  
  5. if ($type == "path") {
  6. if (!empty($path)) {
  7. if (file_exists($path) && is_file($path)) {
  8. $file = file($path);
  9. if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=0;
  10. $file = join('', $file);
  11. } else {
  12. die ("No such file.");
  13. }
  14. } else {
  15. die ("No file specified.");
  16. }
  17. } elseif ($type == "file") {
  18. if (!empty($file)) {
  19.  
  20. } else {
  21. die ("No file specified.");
  22. }
  23. } else {
  24. die ("No file specified.");
  25. }
  26.  
  27. # specify html file, check for doctype
  28. //$file = file("file.html");
  29. //if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=1;
  30. //$file = join('', $file);
  31.  
  32. # make tags and properties lower case, close empty elements, quote all properties
  33. $search = array ("'(<\/?)(\w+)([^> ]*>)'e",
  34. "'(<\/?)(br|input|meta|link|img)([^> ]*)( />)'ie",
  35. "'(<\/?)(br|input|meta|link|img)([^> ]*)(/>)'ie",
  36. "'(<\/?)(br|input|meta|link|img)([^> ]*)(>)'ie",
  37. "'(\w+=)(\w+)'ie",
  38. "'(\w+=)(.+?)'ie");
  39. $replace = array ("'\\1'.strtolower('\\2').'\\3'",
  40. "'\\1\\2\\3>'",
  41. "'\\1\\2\\3>'",
  42. "'\\1\\2\\3 /\\4'",
  43. "strtolower('\\1').'\"\\2\"'",
  44. "strtolower('\\1').'\\2'");
  45. $file = preg_replace($search, $replace, $file);
  46.  
  47. # return xhtml-compliant document
  48. echo "<textarea cols=\"100\" rows=\"20\"> ";
  49. if (isset($doctype)) echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'."\n";
  50. echo stripslashes(stripslashes(stripslashes($file)));
  51. echo "</textarea> ";
  52.  
  53. } else {
  54. ?>
  55. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
  56. <head> <title> HTML -> XHTML Convertor</title> </head>
  57.  
  58. <body>
  59.  
  60. <!-- WARNING: this input method is a security risk on open servers //-->
  61. <form action="<?=$PHP_SELF?>" method="get">
  62. <input type="hidden" name="type" value="path" />
  63. <font face="verdana">File path:</font> <input type="text" name="path" size="50" />
  64. <input type="submit" value="Submit" />
  65. </form>
  66.  
  67. <b><font face="verdana">OR</font></b><br /><br />
  68.  
  69. <form action="<?=$PHP_SELF?> " method="get">
  70. <input type="hidden" name="type" value="file" />
  71. <font face="verdana"> File contents:</font> <br />
  72. <textarea name="file" rows="10" cols="50"> </textarea> <br />
  73. <input type="submit" value="Submit" />
  74. </form>
  75.  
  76. </body>
  77.  
  78. </html>
  79. <?
  80. }
  81. ?>
Opensource XHTML Generator and XHTML Parser in C .
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 5
Reputation: Innocent is an unknown quantity at this point 
Solved Threads: 1
Innocent Innocent is offline Offline
Newbie Poster

Re: XHTML Complient parser?

 
0
  #8
Jul 4th, 2004
If you're still looking, google "HTML Tidy". If that fails, it's on the W3C site somewhere.
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 4
Reputation: linladen is an unknown quantity at this point 
Solved Threads: 0
linladen linladen is offline Offline
Newbie Poster

Re: XHTML Complient parser?

 
0
  #9
Jul 7th, 2004
Hi,
In the past few days i have done enough R&D in this arena.
Has anyone come across / used a XHTML Parser generator
tool in Opensource community developed in C ?
Do Kindly post the link / tool name .

I saw Amaya but it is big and will consume time
to get just the XHTML Parser / Generator from it.

1) GENX is XML Parser and No XHTML Parser / Generator
tool
developed using GENX by GENX till now.

2) EXPAT doesnt provide a opensource XHTML Parser /
Generator till today.

3) X-Smiles is simple and good but Java Based .

4) LibXml is also a library and no XHTML parser /
Generator Tool by them in opensource till today.

Has Someone got a simple setup with just
the XHTML Parser and Generator alone developed in C
available in OpenSource
or
A tool Develped Using the above library tools ?

Kindly let me know And Do Give me your link.

Thanks & Regards,
karthik bala guru

Originally Posted by Innocent
If you're still looking, google "HTML Tidy". If that fails, it's on the W3C site somewhere.
Hi,
In the past few days i have done enough R&D in this arena.
Has anyone come across / used a XHTML Parser generator
tool in Opensource community developed in C ?
Do Kindly post the link / tool name .

I saw Amaya but it is big and will consume time
to get just the XHTML Parser / Generator from it.

1) GENX is XML Parser and No XHTML Parser / Generator
tool
developed using GENX by GENX till now.

2) EXPAT doesnt provide a opensource XHTML Parser /
Generator till today.

3) X-Smiles is simple and good but Java Based .

4) LibXml is also a library and no XHTML parser /
Generator Tool by them in opensource till today.

Has Someone got a simple setup with just
the XHTML Parser and Generator alone developed in C
available in OpenSource
or
A tool Develped Using the above library tools ?

Kindly let me know And Do Give me your link.

Thanks & Regards,
karthik bala guru
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC