Once you've parsed an XML file and turned it into…a JDOM document, the next step is to extract its data…just as with document object model, you'll need to deal with…both attributes and elements but in JDOM, it takes less code.…I’m working in a version of the project called JDOMGetData.…And the code is already in place to parse the XML file.…I won't need this debugging code that's outputting…the XML document so I'll comment it out.…And I'll add code here after the document has been built.…
The first step is to get a list of the elements.…In our XML file each data element has a name…of custumer and it's a child of the root element.…So to get that data, I'll start by getting a reference to the root Element.…I'll create a variable datatyped as a JDOM element.…And…I'll name it root.…Then I'll get its reference by calling the document object's getRootElement method.…Next, I'll walk down one level from the…root element and get all of the child elements.…
To do this, call a method a the element class called getchildren().…
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: Getting data from XML with JDOM