In this tutorial, we will see how to add and remove child node in an xml Document tree. We can add child any where in xml document tree with the help of JDOM API. JDOM is a library used for manipulating xml documents.
In this example, we are discussing the use of addContent() method. Example also show how to delete a child Element. The addContent(Content child) method of Element class adds element at end of child list.
Code:SetNewName.java
package roseindia;
|
|
<?xml version="1.0" encoding="UTF-8"?> <Company> <Employee name="satya" age="25" /> <Employee key="056" /> <CompInfo name="Roseindia.net" /> </Company> |