Home » Core Java » xml » parsers » DocumentBuilder

DocumentBuilder

Count XML Elements in Java using DOM parser example

In this example we are going to see how to count elements with specific tag names using a DOM parser in Java. Basically all you have to do in order to count elements in an XML elements is: Open and parse an XML Document using a DocumentBuilder Use Document.getElementsByTagName that will return a list with nodes. Simply print out the ...

Read More »

Create XML File in Java using DOM parser example

In this tutorial we are going to see how to create XML File in Java using DOM parser. The basic idea is very simple. You construct the DOM object with the tree structure you want in the memory, and then you use a Transformer and a StreamResult in order to write the DOM object to a stream, in our case ...

Read More »

Modify XML File in Java using DOM parser example

With this tutorial we shall show you you can read and modify the contents of an XML File using a DOM parser. The basic idea is pretty straight forward. You read the XML File and use a DOM parser to parse it and construct the DOM object in the memory. Then you can just select any item you want from ...

Read More »

Read XML File in Java using DOM parser example

In this tutorial we are going to see how to use the built in Java DOM parser in order to parse an XML file into a DOM Object As you might know, the DOM object has the classic Tree Structure with nodes, elements, attributes etc… Remember that DOM parser reads the XML file and constructs the DOM object in the ...

Read More »