In this tutorial, we will see how to add a list of
attribute to a xml file element with the help
of JDOM library.
With the help of this java code, you can add a list of
attribute. By using Attrribute class we
will create number
of attribute, which we want to add to xml element. The add() method of
ArrayList
add attribute in ArrayList. The setAttribute(java.utill.ArryList newAttr)
of
Element class add attribute list at xml element.
book.xml
<?xml version="1.0" encoding="UTF-8"?>
|
AddAttributeList.java
package roseindia;
|
|
After adding attribute list in xml file. <?xml version="1.0" encoding="UTF-8"?> <BookCatalog> <book id="22" Auther="xyz" type="program"> <name>Java</name> <year>2000</year> < /book> <book> <name>c</name> <year>1986</year> </book> </BookCatalog> |
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.