Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
XML and Related Technologies
white xml jdom
Nouf Nassri
Ranch Hand
Posts: 40
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello,
I created a file test.xml
<?xml version="1.0" encoding="UTF-8"?> <customer> <code /> <name /> <city /> </customer>
java
import java.io.FileOutputStream; import java.io.OutputStream; import javax.swing.JOptionPane; import org.jdom.*; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; public class CreerXML { public static Element root = new Element("customer"); public static Document document = new Document(root); public static void main(String args[]){ Element code= new Element("code"); root.addContent(code); Element name= new Element("name"); root.addContent(name); Element city = new Element("city"); root.addContent(city); save("test.xml"); } public static void save(String file){ try { XMLOutputter out= new XMLOutputter(Format.getPrettyFormat()); out.output(document, new FileOutputStream(file)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } } }
and I know how I can write the following attributes in test.xml whenever I click the save button.
String code=code.getText(); String name=name.getText(); String city=city.getText();
thanks
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
SAX builder causes the problem, why?
DOM (xml) question
Getting XML Out of a org.w3c.dom.Document
How to save the content withen a table into a XML file?
xml - addAttribute(..) error
More...