DOM question

Diez B. Roggisch deetsNOSPAM at web.de
Thu Jun 2 14:34:47 CEST 2005


> However, I got exactly the same problem: each time I use this function I
> just get a DOM Text node with a few white space (tabs and returns) in
> it. I guess this is the indentation in my source document? But why do I
> not get the propert element nodes?

Welcome to the wonderful world of DOM, Where insignificant whitespace
becomes a first-class citizen!

Use XPath. Really. It's well worth the effort, as it is suited for exactly
the tasks you presented us, and allows for a concise formulation of these.
Yours would be (untested)

//section[id==$id_param]/node()[!name() == section]

It looks from the root throug all the descending childs 

//

after nodes with name section

section

that fulfill the predicate 

[id==$id_param]

>From this out we collect all immediate children

/node()

that are not of type section [!name() == section]


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list