Benoit,
I think you should have a map<string, DOM_Element> rather than <string,
DOM_Element*>. (DOM_Element, like almost all DOM_XXX classes is a kind of
smart pointer).
But then, why have a map at all? The DOM API allows easy access to nodes and
all that - it's what it's for.
Ta, evert
> -----Original Message-----
> From: Benoit Lefevre [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 31, 2001 10:24 AM
> To: [EMAIL PROTECTED]
> Subject: pointing to a DOM object problem ...
>
>
>
>
> Hi
>
> I'm having troubles to use the DOM part of Xerces C++.
> On one hand i have a DOM object that i've loaded from a XML file.
> On the other hand i have my own acces structure (a map).
>
> My problem is to be able to fill my structure according to
> the DOM object.
> Actualy my map is a <string,DOM_Element *> map.
> I'd like to use it to have a quick access to some part of
> the DOM object.
> when i parse the DOM object to fill my map i use this kind of code :
>
> void recursiveFill(DOM_Element &theDom)
> {
>
> ...
> myMap_.insert( pair<string,DOM_Element *>(aString, &theDom));
> ...
>
> DOM_NODEList theList = theDom.getChildNodes();
> for( int i=0 ; i < theList.getLength() ; i++ )
> if(theList.item(i).getNodeType == DOM_Node::ELEMENT_NODE)
> recursiveFill( (DOM_Element &) theList.item(i));
> ...
> }
>
>
> the problem is :
>
> - when i've finished to fill my map, all the pair that have been
> store inside are pointing to the same DOM_Element !?!!?
> (memory speeking).
>
> - when i try to display the memory address of the "theDom"
> variable during the
> recusive calls, this one never change !?!!??!
>
> - even if the address of "theDom" variable never change, the
> data it's
> representing change (during recusive calls).
>
> i guess it is due to the use of a function call by
> reference, but i'm not that good
> in C++ to correct the problem.
>
> None the less, i've tryed to use pointers insted of
> references, but except a new
> casting problem it didn't change anything
>
> If someone have an idea, a clue, an advice or even better an
> exemple ...
> i'm higly interessed.
>
> PS: sorry, i'm not fluent in english neither :).
>
> thank you.
>
> benoit lefevre
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]