DOM question
Richard Lewis
richardlewis at fastmail.co.uk
Thu Jun 2 09:44:37 EDT 2005
On Thu, 02 Jun 2005 14:34:47 +0200, "Diez B. Roggisch"
<deetsNOSPAM at web.de> said:
> > 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]
>
>
Yes, in fact:
//section[@id=$id_param]//*[name()!='section']
would do the trick.
I was trying to avoid using anything not in the standard Python
distribution if I could help it; I need to be able to use my code on
Linux, OS X and Windows.
The xml.path package is from PyXML, yes? I'll just have to battle with
installing PyXML on OS X ;-)
Cheers,
Richard
More information about the Python-list
mailing list