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 Ryan Koss <rk...@acmepacket.com> on 2001/04/30 20:22:04 UTC

DOM to DOM

Hello All,

This maybe have been answered before but I haven't found it in any threads or on the FAQ or grepping around in the samples.

I have one object DOM1 that was parsed from an existing file.  I have another object DOM2 created by a user that is a subset of the DOM1 object.  DOM2 is only attributes that a user wanted to change in DOM1.  Is there a method or easy way to propagate this changes back into DOM1?

For example:
DOM1
<pitcher
    era='2.15'
    bb='8'
    k='25'/>

DOM2
<pitcher
    era='3.05'/>

Right now the only way that I can see to do this is to cycle through all the child nodes in DOM2 get the particular attributes names that reside in DOM2 then find the attribute in DOM1, take the attribute value from DOM2 with a get and then take this value and set it in DOM1 with a set call???  Is this the only way to do a merge of sorts?  Has anyone done this before?  Can anyone offer an insight or better way to complete this particular task? 

Any help or ideas would be greatly appreciated.  Thanks.

-ryan

Re: DOM to DOM

Posted by "Scott A. Herod" <he...@interact-tv.com>.
I've done this but only in the case that DOM2 has about a dozen lines
and DOM1 no more than a couple of hundred.  Essentially, I did exactly
what you suggest below.  Mine's a bit easier because all of my nodes
had better have a unique identifier ( or else other bad things are
going to happen ).  My structure looks more like:

DOM1:
<pitcher name='Smith'
    era='2.15'
    bb='8'
    k='25'/>

DOM2:
<pitcher name='Smith'
    era='3.65' />

I then get all of the pitcher nodes, search for the one named 'Smith',
search for the tag 'era' and change DOM1.  Actually this doesn't break
(die horribly) if there are two Smith's but there is no guarantee which
Smith gets changed.

Scott

> Ryan Koss wrote:
> 
> Hello All,
> 
> This maybe have been answered before but I haven't found it in any
> threads or on the FAQ or grepping around in the samples.
> 
> I have one object DOM1 that was parsed from an existing file.  I have
> another object DOM2 created by a user that is a subset of the DOM1
> object.  DOM2 is only attributes that a user wanted to change in
> DOM1.  Is there a method or easy way to propagate this changes back
> into DOM1?
> 
> For example:
> DOM1
> <pitcher
>     era='2.15'
>     bb='8'
>     k='25'/>
> 
> DOM2
> <pitcher
>     era='3.05'/>
> 
> Right now the only way that I can see to do this is to cycle through
> all the child nodes in DOM2 get the particular attributes names that
> reside in DOM2 then find the attribute in DOM1, take the attribute
> value from DOM2 with a get and then take this value and set it in DOM1
> with a set call???  Is this the only way to do a merge of
> sorts?  Has anyone done this before?  Can anyone offer an insight
> or better way to complete this particular task?
> 
> Any help or ideas would be greatly appreciated.  Thanks.
> 
> -ryan

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org