XML is usually used to store light configuration that controls the business flow or the layout of an application, it’s meant to be managed by business users in the production phase due to its simple human-readable syntax. A typical example is to store the default theme/layout of the application, control the accepted currencies of a financial application, turning on/off features...
Although the main purpose of XML documents is to store lightweight data for faster processing, they are still used in some small applications as a data store which requires dynamic modification. In this article we show how to modify an XML document using DOM in Java. You can still refer to previous articles which cover how to create and parse...
STAX is yet another parser for reading and parsing XML documents in Java, it is very similar to SAX where they both parse the XML document on call and provide events to the developer in order to handle each read tag separately, unlike DOM which stores the XML as a document in the memory. The main difference between SAX and...
In the previous article we talked about DOM parser and provided different examples for parsing and reading elements of an XML document. SAX parser is yet another XML parser provided by JDK which parses documents in a more optimized and faster way. SAX parser doesn’t load the whole document into the memory, however it parses the document line by line...
In this tutorial, we show how to create a new XML file using DOM parser provided by JDK. We’re going to create an XML called students.xml which lists students along with their basic information. 1- Create XML using Transformer The following code snippet appends 3 student elements to a root element called students and then transforms the document object to...
In this tutorial, we show how to read and parse an XML file using DOM parser provided by JDK. If you’re interested in SAX or STAX parser, please refer to these tutorials: SAX parser, STAX parser. 1- Students.xml Consider we have the following Students.xml file:
2- Instantiate XML file DOM parser loads the whole XML document into the memory and considers every XML tag...