943,369 Members | Top Members by Rank

Ad:
Feb 7th, 2003
0

XHTML Complient parser?

Expand Post »
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" />
Similar Threads
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 7th, 2003
0
Re: XHTML Complient parser?
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??
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 7th, 2003
0
Re: XHTML Complient parser?
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?
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Feb 8th, 2003
0
Re: XHTML Complient parser?
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.
Moderator
Reputation Points: 322
Solved Threads: 28
The C# Man, Myth, Legend
Tekmaven is offline Offline
914 posts
since Feb 2002
Feb 15th, 2003
0
Re: XHTML Complient parser?
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. ?>
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002
Feb 15th, 2003
0
Re: XHTML Complient parser?
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).
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Jun 28th, 2004
0

Open Source XHTML Generator and XHTML Parser in C

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


Quote 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 .
Reputation Points: 10
Solved Threads: 0
Newbie Poster
linladen is offline Offline
4 posts
since May 2004
Jul 4th, 2004
0

Re: XHTML Complient parser?

If you're still looking, google "HTML Tidy". If that fails, it's on the W3C site somewhere.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Innocent is offline Offline
5 posts
since Jul 2004
Jul 7th, 2004
0

Re: XHTML Complient parser?

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

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
linladen is offline Offline
4 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: How to make title bar not dissappear when changing pages
Next Thread in HTML and CSS Forum Timeline: How do import a worksheet to HTML?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC