AW: Buffer restriction in dom.minidom?

O

Oliver Walczak

Can i call normalize to the dom root node so that all adjacent child text
nodes attached to one of the element nodes are joined?

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:p[email protected]] Im Auftrag
von Fredrik Lundh
Gesendet: Freitag, 28. November 2003 12:14
An: (e-mail address removed)
Betreff: Re: Buffer restriction in dom.minidom?


Oliver said:
In one of my projects i use dom.minidom as XML parser. I recently had a
problem when the value of a text node as a child of an element node was
larger than 1024 characters. It created 2 or more child nodes out of it so i
had to concatenate both items again manually. On another machine it only
created one child node out of the text node as i further expected although
both are running Python 2.2.3 on WinXP.
Does anyone know whats going on there?

the parser may chose to split CDATA over multiple Text nodes:

http://www.python.org/doc/current/lib/dom-text-objects.html

"A single CDATA section may be represented by more than one
node in the document tree."

if this matters to your program, use "normalize" before accessing the
contents:

http://www.python.org/doc/current/lib/dom-node-objects.html

(using normalize is a good idea even if you're using a normalizing parser;
it prevents nasty surprises the day you or someone else wants to use
your code on a DOM tree created by some other part of your program...)

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top