Home Xml Dom Java DOM Tutorial
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java DOM Tutorial

Advertisement
In this section, you will learn to count the element in XML document using DOM APIs defined in the org.apache.xerces.parsers.DOMParser package.

Java DOM Tutorial

     

This tutorial is complete guide to DOM processing.

What is DOM?

Document Object Model: DOM is a platform- and language-neutral interface, that provides a standard model of how the objects in an XML object are put together, and a standard interface for accessing and manipulating these objects and their inter-relationships.

The DOM is an interface that exposes an XML document as a tree structure comprised of nodes. The DOM allows you to programmatically navigate the tree and add, change and delete any of its elements.

The DOM programming interface standards are defined by the World Wide Web Consortium (W3C). The W3C site provides a comprehensive reference of the XML DOM.

  1. Creating Blank DOM Document
    This section shows you how to create the blank DOM document.
      

  2. Adding Child Elements to the DOM tree
    This lesson shows you how to create root and child elements in the DOM tree.

     

  3. Getting The XML Root Element
    After reading this section, you will be able to retrieve a  root element from the XML document.  The JAXP (Java APIs for XML Processing) provides a common interface for creating and using xml files using the standard SAX, DOM and XSLTs.
      
  4. To Count XML Element
    In this section, you will learn to count the elements present in a  XML file using DOM APIs. 
     
  5. To Count The Elements in a XML File
    In this section, you will learn to count the element in XML document using DOM APIs defined in the org.apache.xerces.parsers.DOMParser  package.
      
  6. XML Well-Formed-ness
    In this section, you will learn to check the well-formed-ness  of a XML using the DOM interface. A  well-formed  XML  document must follow the xml syntax rules.

  7. Searching an Element in the given XML Document
    In this you will learn to search an element in the specified XML document using DOM APIs defined in the org.apache.xerces.parsers.DOMParser  package.
     
  8. Create - XML File (Document)
    In this section, you will  learn to create a XML document using the DOM APIs. This XML document uses  1.0 version  and UTF-8 encoding. 

  9. Regenerating XML  file
    In this section, you will learn to get the  elements and its value using DOM APIs. 

  10. XML Error checker and locater (DOM)
    In this section, you will learn to check and locate (line and column number) an error in your XML document using the DOM APIs.  The XML document follows some rules to check its syntax. 
      
  11. Getting all XML Elements 
    In this section, you will learn to retrieve all elements of the XML file using the DOM APIs. This APIs provides some constructors and methods which helps us to parse the XML file and retrieve all elements.
     
  12. Adding DOCTYPE to a  XML File
    In this section, you will learn to add a DOCTYPE to your XML file  using the DOM APIs. 
     
  13. Getting Dom Tree Elements and their Corresponding XML Fragments
    In this section, you will learn to get the elements of a DOM tree and their corresponding XML fragments. Each element of dom tree has a node level starting with '0'. Here the DOM tree elements and their corresponding XML fragments are displayed on the console.
     
  14. Cloning a XML Element
    In this section, you will learn to create a clone of a  element in the DOM tree. In general, the cloning means to create a duplicate.
     
  15. Remove Element from XML Document
    In this section, you will learn to remove any element from a given  XML document. Whenever you remove the xml element from the xml document the data are also lost from the xml element.
      
  16. Getting Data from XML File (Document)
    In this section, you will learn to retrieve the data from a XML file. All xml files store the data. You can add and modify the data in the  xml document using the DOM APIs.
     
  17. Storing Data (Retrieved from a XML Document) to a File
    In this section, you will learn to store data (retrieved from the XML document) to a specified file (with  extension '.txt', '.doc', '.xls', '.shtml' etc.) in different formats (text, xml, html etc.). 
      
  18. XML Validate DTD 
    In this section, you will learn to validate a xml file against a  DTD (Document Type Definition)  using the DOM APIs. A DTD defines  the document structure with a list of legal elements and attributes.
     
  19. Accessing XML file from Java
    In this example we have provided you a simple java example with the source code that will make it possible to access the XML file through Java. For that we have used DOM parser.
     

XML Tutorials Links
Links of Many XML Tutorials. Here you will find lots of XML Tutorials.

 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 26, 2008

Ask Questions?    Discuss: Java DOM Tutorial   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
vinay
October 1, 2011
core java

why core java having more logic in the programs,example sorting of the programming,grade of the student,and many more.
hanan
June 1, 2012
software engineering

how to use create and use xml files in my project?
DMCA.com