Python 3 - xml - crlf handling problem

durumdara durumdara at gmail.com
Wed Nov 30 07:08:13 EST 2011


Hi!

As I see that XML parsing is "wrong" in Python.

I must use predefined XML files, parsing them, extending them, and
produce some result.

But as I see that in Windows this is working wrong.

When the predefined XMLs are "formatted" (prettied) with CRLFs, then
the parser keeps these plus LF characters (not handle the logic that
CR = LF = CRLF), and it is appearing in the new result too.

    xo = parse('test_original.xml')
    de = xo.documentElement
    de.setAttribute('b', "2")
    b = xo.toxml('utf-8')
    f = open('test_original2.xml', 'wb')
    f.write(b)
    f.close()

And: if I used text elements, this can extend the information with
plus characters and make wrong xml...

I can use only "myowngenerated", and not prettied xmls because of this
problem!

Is this normal?

Thanks for your read:
   dd



More information about the Python-list mailing list