I've previously described how to output an XML document…in JDOM to a string, using the class XML outputter.…The XML outputter class has a structure method.…And you can pass in a format object to determine the format of the XML string.…And of course, once you have a string, you can output that to anywhere.…But if your goal is to create an XML file say on disk, you can use…a shortcut.…I'm working in a project called JDOMTtoXMLFile.…
And I'll add just a couple more lines of code.…I'm in the main method of the create XML with JDOM class.…I've already created the XML outputter object and…used it once to create the XML string.…And I don't need to recreate it.…I can use that object again to create a file.…The outputter object…has a method called output.…Just like the output string method, you can pass in a number of…different types of XML objects: documents, elements, C data sections and so on.…
But then the output method has a second argument, and…you can pass in an output stream or a writer object.…I'll use the Java file writer class.…
Author
Released
11/8/2013- Choosing a Java-based XML API
- Reading XML as a string
- Comparing streaming and tree-based APIs
- Parsing XML with SAX
- Creating and reading XML with DOM
- Adding data to an XML document with JDOM
- Reading and writing XML with StAX
- Working with JAXB and annotated classes
- Comparing Simple XML Serialization to JAXB
Skill Level Intermediate
Duration
Views
Related Courses
-
Introduction
-
Welcome55s
-
What you should know1m 43s
-
Using the exercise files4m 48s
-
-
1. Getting Started
-
Reviewing XML terminology9m 56s
-
Reading XML as a string5m 42s
-
-
2. Parsing XML with SAX (Simple API for XML)
-
How SAX works6m 7s
-
-
3. Creating and Parsing XML with Document Object Model
-
How DOM works7m 56s
-
Creating a DOM document8m 5s
-
-
4. Creating and Parsing XML with JDOM
-
How JDOM works5m 52s
-
-
5. Creating and Parsing XML with StAX
-
How StAX works6m 11s
-
-
6. Creating and Parsing XML with JAXB
-
7. Creating and Parsing with Simple XML Serialization
-
Comparing Simple to JAXB3m 59s
-
-
Conclusion
-
Next steps1m 7s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Outputting an XML file with JDOM