Simon Willison’s Weblog

Subscribe

Benefits of XHTML

11th August 2002

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.

Next: One for Paul

Previous: Offline until Sunday

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