Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Benefits of XHTML

Phil Ringnalda is questioning the point of XHTML. The single, huge advantage it has over HTML is that XHTML can be parsed by anything (or any language) with an XML parser. As an example, a few weeks ago I was asked to write a script to grab links from a bunch of HTML pages and insert them in to a database. I solved the problem with a combination of PHP’s strip_tags() function and XML parsing abilities, by killing off every tag that wasn’t an <a> tag and slapping on a start and end element to turn the document in to valid XML—a step that would not have been necessary had the page used XHTML in the first place.

While upgrading to XHTML may have few immediate benefits, the ease with which it can be parsed has very real benefits further down the line. Writing content in XHTML now will make it much easier to re-use that content in the future.

Update: I should have checked the date on his entry before I posted—this is from way back in December 2001

This is Benefits of XHTML by Simon Willison, posted on 11th August 2002.

View blog reactions

Next: One for Paul

Previous: Offline until Sunday

2 comments

  1. Just had another look at the date on that post and it's from December 2001 :) I should probably have checked that before I jumped in guns-a-blazing - I got the link from the MACCAWS mailing list and assumed it was recent.

    Simon - 11th August 2002 19:27 - #

  2. the post ends with "Thanks, I'll skip this revolution." but i checked out the front page and viewed source:

    <?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-transition al.dtd">

    dean - 12th August 2002 13:14 - #

Comments are closed.

Previously hosted at http://simon.incutio.com/archive/2002/08/11/benefitsOfXhtml

A django site