I've never used SAXBuilder...

Are you sure that $newelem.toString() always displays the same as $newelem.getText()

----- Original Message ----- From: "Anagha" <[EMAIL PROTECTED]>
To: "velocity-user" <velocity-user@jakarta.apache.org>
Sent: Tuesday, February 07, 2006 12:34 AM
Subject: XML building - velocity 1.4


Hi,
I want to build xml by replacing existing XML text elements with some other
text.
I built the Document with SAXBuilder and put the root element in the
context.
My template is like this :

#set ($rootelem = $root.getRootElement())
$rootelem

#foreach($elem in $rootelem.getChildren())
   #set ($newelem = $elem)

   #if ($elem.getName().equalsIgnoreCase("serviceInstanceId"))
       got it
       $newelem.getText()
       $newelem.setText("OTHERTEXT")
       $newelem
   #end
#end

When I merge with the template, I get the text of the existing node
correctly( $newelem.getText())
After setText when I print the $newelem I expect the new text (OTHERTEXT) in
the element.
But I get the empty element. I never see new  text element in the element.

Any help is appreciated.

--
Thanks & Regards,
Anagha


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to