Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Java & XML-DOM. Change the tag name of an Element object.

Thread view: 
David  Portabella - 28 Jul 2007 06:25 GMT
Using the Java package org.w3c.dom,
I have an Element object.
How can I change the tagName of a given Element?

There is the method Element.getTagName(),
but I did not find the method Element.setTagName() or equivalent.

One solution could be to create a new Element, with the new name, move
all the children and attributes from the old element to the new one,
and to replace the old element for the new one in the tree.

Is there a simpler and more natural solution?
some xml util package (that works with org.w3c.dom)?

DAvid
JTL.zheng - 28 Jul 2007 07:10 GMT
you can try JDOM(www.jdom.org)
it can rename a element:
----------
Element el = doc.getRootElement();
el.setName("newName");
------------
Mike Schilling - 28 Jul 2007 17:21 GMT
David Portabella wrote:
> Using the Java package org.w3c.dom,
> I have an Element object.
[quoted text clipped - 8 lines]
>
> Is there a simpler and more natural solution?

No.  What you described is the only way to do it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.