You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Anuj Seth <an...@sasi.com> on 2000/07/13 15:51:03 UTC

Reference to the object returned by getFirstChild and getNextSibling???

Hi,

First, I'd like to thank Jeff Lewis and Joseph Kesselman. Their inputs
helped me a lot in writing a XML file merger application. There is just
this one problem that I'm facing and this is keeping me from actually
merging two documents!! :-(

During the DOM document traversal stage, I need to keep references to
certain nodes in the DOM_Document so that I can access them later and
manipulate them immediately. Unfortunately, the getFirstChild() and
getNextSibling() methods of DOM_Node return copies of the object and not
the actual object itself.

The implementation of getFirstChild() is,

DOM_Node DOM_Node::getFirstChild() const
{
    return DOM_Node(fImpl->getFirstChild());
};

As it can be seen, it is returning a copy of the object and not the
object itself. Is there any "replacement" functions for getFirstChild()
and getNextSibling() which returns "live" objects, i.e, the actual
object itself?

I was initially doing,

DOM_Node child = doc2.getFirstChild();

This results in a copy of the copy being created!

So, I changed it to,

DOM_Node &child = doc2.getFirstChild();

Even this does not help because getFirstChild returns a copy and not the
actual node. How can I get the reference to the actual node so that I
can store the reference and then use it later for manipulation?

I need this information very urgently. Any help will be greatly
appreciated.

I hope I've clearly explained the problem that I'm facing.

With Regards,
Anuj