REALLY simple xml reader

Ben Finney bignose+hates-spam at
Thu Jan 31 14:40:01 CET 2008

Steve Holden <steve at> writes:

> Diez B. Roggisch wrote:
> > Ricardo Aráoz schrieb:
> >> doc = """
> >> <?xml version="1.0"?>
> >
> > It's not allowed to have a newline before the <?xml ...>
> >
> > Put it on the line above, and things will work.
> >
> If you don't think that looks pretty enough just escape the first
> newline in the string constant to have the parser ignore it:

Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of
the document <URL:>. Many XML
parsers will (correctly) reject such a document.

> doc = """\
> <?xml version="1.0"?>

This is fine.

 \         "True greatness is measured by how much freedom you give to |
  `\      others, not by how much you can coerce others to do what you |
_o__)                                               want." —Larry Wall |
Ben Finney

More information about the Python-list mailing list