In this tutorial, you will see how to remove attribute of xml element in java.
In this tutorial, you will see how to remove attribute of xml element in java.In this tutorial, we will see how to remove attribute of xml element in java with the help
of
JDOM library. It is a java tool kit for xml parsing.
With the help of this code, we can remove attribute of
element. DOMBuilder is a
class that build a JDOMDocument
of xml file. The getRootElement method of
Document class is
used for accessing root element. The
removeAttribute(String name)
method remove attribute
of an element with given name. The Element class is available
in
org.jdom.Element pacakage.
Element API.
Return Type | Method | Description |
boolean | removeAttribute(String name) | The removeAttribute(...) method remove attribute from existing element. |
student.xml
<?xml version="1.0"?>
|
CloneAttribute.java
package roseindia;
|
After removing attribute xml file. <?xml version="1.0" encoding="UTF-8"?> <Student> <first id="10"> <city>Bly</city> </first> <first id="20" name="ankit"> <city>lko</city> </first> <first id="30" name="gyan"> <city>lko</city> </first> </Student> |