With your document parsed to a dom tree:

Element parent = (Element)domDocument.getElementsByTagNameNS("SOAP-ENV", "Header").item(0);
Element cnnElement =domlDocument.createElement("CNN");
parent.appendChild(cnnElement);


now you can serialize it back.

Jeong Ahn Lee wrote:

THANKS,

but i know how to append an element to a document but,
i want to know how i can insert an element with in an
existing xml document, say, i have a xml file i am
reading it, and i want to insert an element, how can i
do that, that is not given in that example.

thanks


--- Christopher Ebert <[EMAIL PROTECTED]> wrote:


        Hi,

        Try looking at sample
~/samples/dom/DOMGenerate.java. It should
give you everything you need.

        Cheers,

                Chris


-----Original Message----- From: Jeong Ahn Lee [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 2:40 AM To: [EMAIL PROTECTED] Subject: How to insert element?


Hi all, i have an xml document like below

<SOAP-ENV:Envelope>
        <SOAP-ENV:Header>
                <ABC>aa</ABC>
                <BBC>bb</BBC>
                <CNN>bb</CNN>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>this is body</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

in that document, how can i insert an element( say
<FOX> )
after <CNN> element, with in the <SOAP-ENV:Header>
element.

Thanks and Regards
Jeong Ahn

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com




---------------------------------------------------------------------


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]





__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

---------------------------------------------------------------------
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]



Reply via email to