Buffer restriction in dom.minidom?
Fredrik Lundh
fredrik at pythonware.com
Fri Nov 28 06:14:08 EST 2003
Oliver Walczak wrote:
> 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>
More information about the Python-list
mailing list