JDOM / CATATAN</>↗JDOM04 Mei 2009
The following example shows you how to remove attributes from an XML element. We will remove attribute named userid from the <row> element. To remove an attribute you can call the removeAttribute(String name) method of the Element object. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.input.SAXBuilder; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import java.io.File; public class JDOMRemoveAttribute […...
JDOM / CATATAN</>↗JDOM03 Mei 2009
This example show you how to remove an element from XML document. In the code snippet below we start by loading an XML document and display its original contents. After that we find the element <row>, and remove the <address> element from it. To get the first child we are using the getChild() method from […]
JDOM / CATATAN</>↗JDOM02 Mei 2009
The program below will show you how to add attributes to an XML elements. Using JDOM library this can be easily done by calling the Element‘s setAttribute(String name, String value) method. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; public class JDOMAddAttribute { public static void main(String[] args) { Document doc = new […]
JDOM / CATATAN</>↗JDOM28 Apr 2009
In this small program you can see how to use JDOM to create a simple xml file. Below you’ll see how to create elements of the xml document, set some text for the element. After that you can see how to use the XMLOutputter class to write the JDOM document into file and display it […]
JDOM / CATATAN</>↗JDOM28 Apr 2009
The following example show you how to create a simple Document object in JDOM. We can create a new document directly by creating a new instance of the Document class, for additional information we can pass an Element as an argument. To create a Document from an existing XML file we can use the SAXBuilder. […]
SWING / CATATAN</>↗Swing24 Apr 2009
In this example you can see how we can read the items of a JList component. We also obtain the size or the number of items in the JList components. This can be done by calling JList‘s getModel() method which return a ListModel object. From the ListModel we can get the items size, and we […]