In this tutorial, we will see how to create a clone of
attribute in java by using JDOM library.
JDOM is used for parsing, creating,
manipulating, and serializing XML documents, it is
a tree based Java api
In this example, we use few method for creating
clone of attribute. DOMBuilder is a class
that build a JDOMDocument of xml file. The getRootElement method of Document
class
is used for accessing root element. The getAttribute
method returns attribute of element.
The clone method returns
clone of attribute. The Attribute class is available in
org.jdom.Attribute pacakage.
student.xml
<?xml version="1.0"?>
|
CloneAttribute.java
import org.jdom.Attribute;
|
| Attribute Value : bharat
Clone of attribute : [Attribute: name="bharat"] Attribute Value : ankit Clone of attribute : [Attribute: name="ankit"] Attribute Value : gyan Clone of attribute : [Attribute: name="gyan"] |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.