REALLY simple xml reader

Steve Holden steve at holdenweb.com
Thu Jan 31 09:10:50 EST 2008


Ben Finney wrote:
> Steve Holden <steve at holdenweb.com> 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:http://www.w3.org/TR/xml/#sec-prolog-dtd>. Many XML
> parsers will (correctly) reject such a document.
> 
>> doc = """\
>> <?xml version="1.0"?>
> 
> This is fine.
> 
Sure. The only difference in "prettiness" I was referring to was the 
difference betwee

doc = """<?xml ...
<stuff on the left-hand margin>
...

and

doc = """\
<?xml ...
<stuff on the left-hand margin>
...


In other words, Python source-code prettiness.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list