Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

Add attribute in DOM element

This is an example of how to add an attribute in a DOM element. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. Adding an attribute in a DOM element implies that you should: Obtain a new instance of a DocumentBuilderFactory, that is a factory API that enables ...

Read More »

Remove nodes from DOM document recursively

In this example we shall show you how to remove Nodes from a DOM Document recursively. We have implemented two methods, removeRecursively(Node node, short nodeType, String name), in order to remove recursively a Node from a DOM Document and void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. To remove Nodes from a DOM Document recursively ...

Read More »

Remove node from DOM document

With this example we are going to demonstrate how to remove a Node from a DOM Document. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. In short, to remove a Node from a DOM Document you should:  Obtain a new instance of a DocumentBuilderFactory, that is a factory API ...

Read More »

Create DOM document from scratch

This is an example of how to create a DOM Document from Scratch. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. Creating a DOM Document from Scratch implies that you should: Create an new Document, using newDocument() API method of DocumentBuilder. Create the root element node of the ...

Read More »

Add text node to DOM document

In this example we shall show you how to add a Text Node to a DOM Document. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. To add a Text Node to a DOM Document one should perform the following steps: Obtain a new instance of a DocumentBuilderFactory, ...

Read More »

Add node to DOM document

With this example we are going to demonstrate how to add a Node to a DOM Document. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. In short, to add a Node to a DOM Document you should: Obtain a new instance of a DocumentBuilderFactory, that is a ...

Read More »

Add comment to DOM document

This is an example of how to add comments to a DOM Document. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. Adding comments to a DOM Document implies that you should: Obtain a new instance of a DocumentBuilderFactory, that is a factory API that enables applications to obtain ...

Read More »

Add CDATA section to DOM document

In this example we shall show you how to add CDATASection to a DOM Document. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. To add CDATASection to a DOM Document one should perform the following steps: Obtain a new instance of a DocumentBuilderFactory, that is a factory API ...

Read More »

Visit nodes in DOM document recursively

With this example we are going to demonstrate how to visit recursively the nodes in a DOM Document. We have implemented a method void visitRecursively(Node node), in order to visit a node and its children in the DOM Document. In short, to visit recursively the nodes in a DOM Document you should: Obtain a new instance of a DocumentBuilderFactory, that is ...

Read More »

Pretty print XML in Java

This is an example of how to pretty print an xml file in Java. We have implemented a method, that is void prettyPrint(Document xml), in order to transform the DOM Document to a formatted xml String. The steps to get an xml file and pretty print it in a String format using the example’s method is described below: Obtain a new ...

Read More »