Updating xml using jdom
To put XML data into the tree we will use the adapter pattern.This means we will wrap the XML data in wrappers that the JTree can understand and work with.We need to create an "model adapter" that will use the Tree Model interface to explain the JDOM format of XML.Here is the bare bones version of our model adapter: , which in turn contains other Elements.
Document doc = sax Builder.build(new String Reader(xml)); Element root Node = Root Element(); Element sub Root Node = root Child("ns2: Data Content"); Element subsub Root Node = sub Root Child("ns2: Data Item"); Element subsubsub Root Node = subsub Root Child("ns2: Position"); String value=subsubsub Root Attribute Value("ns3: Random Numbers"); println(value); String xml="above xml";
however, when I select a file, the file details are not added to the xml file; and i also get some errors.
But I know that my add File Element(..) method is correct since if I use the following code , I am able to write to a xml file: uploaded File Element("xml.java","directory","size"); So does anyone know why my add File Element(...) is not working properly.
This can be done using the set Attribute() method or setting the node Value property of the attribute node.
Hi I have created a java class that uses JButton to bring up JFile Chooser.