XML and newlines

Hans Nowak wurmy at earthlink.net
Sat Feb 16 12:24:32 EST 2002


Henrik Motakef wrote:
> 
> Hans Nowak <wurmy at earthlink.net> writes:
> 
> Hi.
> 
> First of all, I have to admit that I'm not sure what your problem
> is. :)

That is probably my fault. Here's a short summary. I want to store a
multiline string, containing newlines, in SQL Server, using an
updategram in XML. I post the record. I retrieve the record back.
Newlines are gone from the string.

I get the records back as XML too. In raw, unparsed XML (just a string)
the newlines are still there. As soon as I parse the XML, they are
somehow removed. See my other post to Martin von Loewis.

I don't know much about XML; if whitespace is considered insignificant,
like in HTML, then it might be removed when parsing.

> However, one thing that might possibly be related is that XML parsers
> are required to convert all of the funky end-of-line markers around
> (i.e. "\r\n", "\n", "\r") to a single newline "\n". Scince you Use SQL
> Server, I assume that you are also running Windows, where the
> "official" newline is "\r\n". Could that be related to your problem?

It was part of a previous problem; the XML supposedly only contained \n,
where \r\n was desirable. While investigating it, I stumbled upon a
different, more serious problem-- no newlines at all.

On a side note, any operating system with an Internet connection can talk
to the SQL Server database using SQLXML. All you need is some HTTP
functions (like Python has in httplib) to talk to it. No drivers needed.
All communication with the server is done through XML. Pretty fly for
a M$ product. ;-)

-- 
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==')) 
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/



More information about the Python-list mailing list