Having problems with strings in HTML

Richie Hindle richie at entrian.com
Tue Jun 27 09:57:41 EDT 2006


[Kiana]
> <a href="http://bbc.botany.utoronto.ca/[...]?input=&max=2[...]">

[Lawrence]
> By the way, you _do_ realize that your "&" characters should be escaped 
> as "&", don't you?

[Sion]
> No they shouldn't. They part of the url, which is (IIRC) a CDATA
> attribute of the A element, not PCDATA.

The W3C validator at http://validator.w3.org/ disagrees with you.  It
accepts this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Test</title></head>
<body>
<p><a href="http://somewhere.com?a=1&b=2">link</a></p>
</body></html>

but rejects this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Test</title></head>
<body>
<p><a href="http://somewhere.com?a=1&b=2">link</a></p>
</body></html>

saying "cannot generate system identifier for general entity "b" [...] The
most common cause of this error is unencoded ampersands in URLs".

-- 
Richie Hindle
richie at entrian.com



More information about the Python-list mailing list