RSS Forums RSS
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 8449 | Replies: 8
Reply
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,073
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 118
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

XHTML Complient parser?

  #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

<input type=submit name=submit value=Go>
to
<input type="submit" name="submit" value="Go" />
Dani the Computer Science Gal
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,073
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 118
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
  #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
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,073
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 118
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
  #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:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

It doesn't make any other changes?
Dani the Computer Science Gal
Reply With Quote  
Join Date: Feb 2002
Location: New York
Posts: 862
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 
Rep Power: 12
Solved Threads: 16
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend
  #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

ASP.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  
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Rep Power: 12
Solved Threads: 4
Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor
  #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.

<? 

if (!empty($type)) { 

 if ($type == "path") { 
  if (!empty($path)) { 
   if (file_exists($path) && is_file($path)) { 
    $file = file($path); 
    if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=0; 
    $file = join('', $file); 
   } else { 
    die ("No such file."); 
   } 
  } else { 
   die ("No file specified."); 
  } 
 } elseif ($type == "file") { 
  if (!empty($file)) { 
    
  } else { 
   die ("No file specified."); 
  } 
 } else { 
  die ("No file specified."); 
 } 

 # specify html file, check for doctype 
 //$file = file("file.html"); 
 //if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=1; 
 //$file = join('', $file); 

 # make tags and properties lower case, close empty elements, quote all properties 
 $search  = array ("'(<\/?)(\w+)([^>]*>)'e", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)( />)'ie", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)(/>)'ie", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)(>)'ie", 
                   "'(\w+=)(\w+)'ie", 
                   "'(\w+=)(.+?)'ie"); 
 $replace = array ("'\\1'.strtolower('\\2').'\\3'", 
                   "'\\1\\2\\3>'", 
                   "'\\1\\2\\3>'", 
                   "'\\1\\2\\3 /\\4'", 
                   "strtolower('\\1').'\"\\2\"'", 
                   "strtolower('\\1').'\\2'"); 
 $file = preg_replace($search, $replace, $file); 

 # return xhtml-compliant document 
 echo "<textarea cols=\"100\" rows=\"20\">"; 
 if (isset($doctype)) echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'."\n"; 
 echo stripslashes(stripslashes(stripslashes($file))); 
 echo "</textarea>"; 

} else { 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> 
<head><title>HTML -> XHTML Convertor</title></head> 

<body> 

<!-- WARNING: this input method is a security risk on open servers //--> 
<form action="<?=$PHP_SELF?>" method="get"> 
<input type="hidden" name="type" value="path" /> 
<font face="verdana">File path:</font> <input type="text" name="path" size="50" /> 
<input type="submit" value="Submit" /> 
</form> 

<b><font face="verdana">OR</font></b><br /><br /> 

<form action="<?=$PHP_SELF?>" method="get"> 
<input type="hidden" name="type" value="file" /> 
<font face="verdana">File contents:</font><br /> 
<textarea name="file" rows="10" cols="50"></textarea><br /> 
<input type="submit" value="Submit" /> 
</form> 

</body> 

</html> 
<? 
} 
?> 
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 11,073
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 33
Solved Threads: 118
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb
  #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
Reply With Quote  
Join Date: May 2004
Posts: 4
Reputation: linladen is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
linladen linladen is offline Offline
Newbie Poster

Solution Open Source XHTML Generator and XHTML Parser in C

  #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.

<? 

if (!empty($type)) { 

 if ($type == "path") { 
  if (!empty($path)) { 
   if (file_exists($path) && is_file($path)) { 
    $file = file($path); 
    if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=0; 
    $file = join('', $file); 
   } else { 
    die ("No such file."); 
   } 
  } else { 
   die ("No file specified."); 
  } 
 } elseif ($type == "file") { 
  if (!empty($file)) { 
    
  } else { 
   die ("No file specified."); 
  } 
 } else { 
  die ("No file specified."); 
 } 

 # specify html file, check for doctype 
 //$file = file("file.html"); 
 //if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=1; 
 //$file = join('', $file); 

 # make tags and properties lower case, close empty elements, quote all properties 
 $search  = array ("'(<\/?)(\w+)([^>]*>)'e", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)( />)'ie", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)(/>)'ie", 
                   "'(<\/?)(br|input|meta|link|img)([^>]*)(>)'ie", 
                   "'(\w+=)(\w+)'ie", 
                   "'(\w+=)(.+?)'ie"); 
 $replace = array ("'\\1'.strtolower('\\2').'\\3'", 
                   "'\\1\\2\\3>'", 
                   "'\\1\\2\\3>'", 
                   "'\\1\\2\\3 /\\4'", 
                   "strtolower('\\1').'\"\\2\"'", 
                   "strtolower('\\1').'\\2'"); 
 $file = preg_replace($search, $replace, $file); 

 # return xhtml-compliant document 
 echo "<textarea cols=\"100\" rows=\"20\">"; 
 if (isset($doctype)) echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'."\n"; 
 echo stripslashes(stripslashes(stripslashes($file))); 
 echo "</textarea>"; 

} else { 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> 
<head><title>HTML -> XHTML Convertor</title></head> 

<body> 

<!-- WARNING: this input method is a security risk on open servers //--> 
<form action="<?=$PHP_SELF?>" method="get"> 
<input type="hidden" name="type" value="path" /> 
<font face="verdana">File path:</font> <input type="text" name="path" size="50" /> 
<input type="submit" value="Submit" /> 
</form> 

<b><font face="verdana">OR</font></b><br /><br /> 

<form action="<?=$PHP_SELF?>" method="get"> 
<input type="hidden" name="type" value="file" /> 
<font face="verdana">File contents:</font><br /> 
<textarea name="file" rows="10" cols="50"></textarea><br /> 
<input type="submit" value="Submit" /> 
</form> 

</body> 

</html> 
<? 
} 
?> 
Opensource XHTML Generator and XHTML Parser in C .
Reply With Quote  
Join Date: Jul 2004
Location: Toronto
Posts: 5
Reputation: Innocent is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
Innocent Innocent is offline Offline
Newbie Poster

Re: XHTML Complient parser?

  #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  
Join Date: May 2004
Posts: 4
Reputation: linladen is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
linladen linladen is offline Offline
Newbie Poster

Solution Re: XHTML Complient parser?

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:35 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC