Re: [xml] Question about parent/child (python-libxml2)



On Sun, May 09, 2004 at 03:39:47PM -0400, Daniel Veillard wrote:
  the para node has a list of children. The childens are a doubly
linked list (prev/next) . 
  what you want is the serialization of that list. You can serialize
each children independantly and concatenate the result.

I think, that I did exactly this in the first place :-)  As
I wrote in my initial mail
http://lists.gnome.org/archives/xml/2004-May/msg00078.html,
I did:

#!/usr/bin/env python
import libxml2
dom = libxml2.parseDoc('''<?xml version="1.0"?>
<para role="x">Then, shalt thou count to
<emphasis>three</emphasis>, no more, no less.</para>''')
nodes = dom.xpathEval("//*[ role='x']")
for n in nodes:
    if n.children:
        for c in n.children:
            if c.name == "comment":
                continue
            print c.serialize()

I got:

"Then, shalt thou count to

<emphasis>three</emphasis>
three
, no more, no less."

So my question was/is: How can I get rid of the 'three'
(second last line)?  Sorry for being not clear about the
problem.

Cheers,
-- 
W. Borgert <debacle debian org>, http://people.debian.org/~debacle/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]