Re: how to point to an element in the DOMtree?
Luca Padovani <[email protected]> Wed, 18 May 2005 14:05:23 +0200
| Newsgroups | gmane.comp.gnome.gdome |
|---|---|
| Message-ID | <1116417621.16111.51.camel@tempesta> |
On Wed, 2005-05-18 at 14:39 +0530, Sameer Oak wrote: > But, I am not being able to figure out the way how can I locate to the > root element of the DOM tree, and Also, for that matter, some other > element which is a child element of some element? the gdome_doc_documentElement method does exactly this, it returns the root element of a DOM document. As for reaching a particular element, one has indeed the possibilities you've listed (xpath or walking). In addition, there are a few helper DOM methods that can be useful, in particular getElementsByTagName getElementsByTagNameNS in the Document interface. These methods however can be very inefficient if used for reaching not just one node but a whole list of nodes. In this case I'd recommend walking the tree. Cheers --luca