Re: [xml] Smart way to get ancestors?



Hi!

A small update, this is the way I retrieve the ancestors now:

        node = xmlTextReaderExpand(reader);

        node->children = NULL;
        node->prev = NULL;
        node->next = NULL;

        while (node->parent != NULL) {
                node = node->parent;
        }
        xmlDocSetRootElement(doc,xmlCopyNode(node->children,1));

This works fine - is it a proper way to accomplish this?

Thanks,
Michael


-- 
Michael Ransburg, Dipl.-Ing.
Project Assistant, PhD Candidate
Department of Information Technology (ITEC)
Klagenfurt University / Austria
http://www.ifi.uni-klu.ac.at/ITEC/Staff/Michael.Ransburg
 


_____________________________________________ 
From:         xml-bounces gnome org [mailto:xml-bounces gnome org]  On
Behalf Of Michael Ransburg
Sent: Friday, July 07, 2006 8:12 PM
To:   xml gnome org
Subject:      [xml] Smart way to get ancestors?

Hi!

I'm using the XMLTextReader to parse a document, for example:

<A>
      <B/>
      <C/>
      <D>
              <E/>
              <F>
                      <G/>
              </F>
      </D>
</A>

Now lets say that I reach the node <G> and would like to copy its
ancestors (<A>, <D>, <F>) to a new document. The way I'm currently doing
it is to use some temporary nodes and a lot of "xmlCopyNode(node,2)" in
order to get rid of unwanted siblings. Is there a nicer way to get the
ancestors of a given node as a new document?

Thanks,
Michael


 << File: ATT00007.txt >> 

<<attachment: winmail.dat>>



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