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 ....

 

Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions

 

Add node to DOM document

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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 »

Copy nodes subtree from one DOM document to another

Bipartite Graph

In this example we shall show you how to copy the Nodes Subtree from one DOM Document to another. We have implemented a method, that is void prettyPrint(Document xml), in order to convert a DOM into a formatted XML String. To copy the Nodes Subtree from one DOM Document to another one should perform the following steps: Obtain a new ...

Read More »

Create empty DOM document

Bipartite Graph

With this example we are going to demonstrate how to create an empty DOM Document, that represents the entire HTML or XML document. The DOM Document is the root of the document tree, and provides the primary access to the document’s data. In short, to create an empty DOM Document you should: Obtain a new instance of a DocumentBuilderFactory, that ...

Read More »

Parse XML file with DOM

Bipartite Graph

This is an example of how to parse an xml file using a DOM Document. The DOM Document interface represents the entire HTML or XML document and provides the primary access to a document’s data. Parsing an xml file using a DOM Document implies that you should: Obtain a new instance of a DocumentBuilderFactory, that is a factory API that ...

Read More »

Get element attributes in SAX XML parsing

Bipartite Graph

In this example we shall show you how to get an Element’s Attributes using SAX XML parsing. Simple API for XML (SAX) is an event-driven, serial-access mechanism for accessing XML documents. It is frequently used by servlets and network-oriented programs that need to transmit and receive XML documents, because it is the fastest and least memory-intensive mechanism that is currently available for ...

Read More »

Parse XML file with SAX

Bipartite Graph

With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for accessing XML documents. It is frequently used by servlets and network-oriented programs that need to transmit and receive XML documents, because it is the fastest and least memory-intensive mechanism that is currently available ...

Read More »