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 Paul Tan <ta...@cwc.nus.edu.sg> on 2001/10/30 13:56:05 UTC

Modifying DOM_Node

Hi,

I have the following XML structure ...

<Friends>
    <Friend name="Paul">
        <Hobby type="sport"/>
        <Hobby type="reading"/>
            <GirlFriend name="Pauline">
                <Hobby type="sport"/>
                <Hobby type="reading"/>
            </GirlFriend>
            <GirlFriend name="Paula">
                <Hobby type="sport"/>
                <Hobby type="reading"/>
            </GirlFriend>
     </Friend>
    <Friend name="John">
        <Hobby type="sport"/>
        <Hobby type="reading"/>
    </Friend>
</Friends>

I would like to know how to use Xerces XML DOM API to modify intermediate
DOM_Node (e.g "Pauline's hobby") efficiently ? Initially I attemptted to
remove it and then add it (modify version) again ....and when I finally
write to the file, the modified DOM_Node get added at the bottom ....

Please advice.

Thank you.
Paul


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


Re: Modifying DOM_Node

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Paul Tan" <ta...@cwc.nus.edu.sg> writes:

> I would like to know how to use Xerces XML DOM API to modify intermediate
> DOM_Node (e.g "Pauline's hobby") efficiently ? Initially I attemptted to
> remove it and then add it (modify version) again ....and when I finally
> write to the file, the modified DOM_Node get added at the bottom ....

No need to remove the node. Just find it, and modify it. appendChild()
does just that appends a node to the end of the child list. If you
want to position a node at a specific point you need to use
insertBefore().

jas.

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


RE: Modifying DOM_Node

Posted by Erik Rydgren <er...@mandarinen.se>.
Look at the methods setAttribute and removeAttribute in DOM_Element and/or
methods appendChild, removeChild and replaceChild in DOM_Node.
They should do the trick for you.

Regards
Erik Rydgren
Mandarinen systems AB
Sweden

-----Original Message-----
From: Paul Tan [mailto:tanpaul@cwc.nus.edu.sg]
Sent: den 30 oktober 2001 13:56
To: xerces-c-dev@xml.apache.org
Subject: Modifying DOM_Node


Hi,

I have the following XML structure ...

<Friends>
    <Friend name="Paul">
        <Hobby type="sport"/>
        <Hobby type="reading"/>
            <GirlFriend name="Pauline">
                <Hobby type="sport"/>
                <Hobby type="reading"/>
            </GirlFriend>
            <GirlFriend name="Paula">
                <Hobby type="sport"/>
                <Hobby type="reading"/>
            </GirlFriend>
     </Friend>
    <Friend name="John">
        <Hobby type="sport"/>
        <Hobby type="reading"/>
    </Friend>
</Friends>

I would like to know how to use Xerces XML DOM API to modify intermediate
DOM_Node (e.g "Pauline's hobby") efficiently ? Initially I attemptted to
remove it and then add it (modify version) again ....and when I finally
write to the file, the modified DOM_Node get added at the bottom ....

Please advice.

Thank you.
Paul


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


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


RE: Modifying DOM_Node

Posted by Sascha Presnac <sa...@bestcolor.com>.
Hi,

i would like to know, _how_ do you save the xml file with xerces.
I try it with the DOMSerializer, but VisualStudio fails to compile the
constructor in the .hpp file:
DOMSerializer (const std::string& encoding << defaultEncoding_);

The errors reported are:
C2629,C2238,C2629,C2238

Please help, so i can save my XML Files, thanks...

Regards,
Sascha Presnac

 #>-----Original Message-----
 #>From: Paul Tan [mailto:tanpaul@cwc.nus.edu.sg]
 #>Sent: Tuesday, October 30, 2001 1:56 PM
 #>To: xerces-c-dev@xml.apache.org
 #>Subject: Modifying DOM_Node
 #>
 #>
 #>Hi,
 #>
 #>I have the following XML structure ...
 #>
 #><Friends>
 #>    <Friend name="Paul">
 #>        <Hobby type="sport"/>
 #>        <Hobby type="reading"/>
 #>            <GirlFriend name="Pauline">
 #>                <Hobby type="sport"/>
 #>                <Hobby type="reading"/>
 #>            </GirlFriend>
 #>            <GirlFriend name="Paula">
 #>                <Hobby type="sport"/>
 #>                <Hobby type="reading"/>
 #>            </GirlFriend>
 #>     </Friend>
 #>    <Friend name="John">
 #>        <Hobby type="sport"/>
 #>        <Hobby type="reading"/>
 #>    </Friend>
 #></Friends>
 #>
 #>I would like to know how to use Xerces XML DOM API to modify intermediate
 #>DOM_Node (e.g "Pauline's hobby") efficiently ? Initially I attemptted to
 #>remove it and then add it (modify version) again ....and when I finally
 #>write to the file, the modified DOM_Node get added at the bottom ....
 #>
 #>Please advice.
 #>
 #>Thank you.
 #>Paul
 #>
 #>
 #>---------------------------------------------------------------------
 #>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
 #>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


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