Consultancy Services jobs Etisalat CEO ZANTEL
etisalat

Custom Search
Share/Save/Bookmark Subscribe

Java XML part 4

Posted by Anonymous | 6:50 PM | | 0 comments »

Java XML





JAVA XML API
The main three main APIs that we shall focus on are:
1.JAXP – Parsing API.
2.JAXM – Messaging API.
3.JAXB – Binding API.

Java API for XML Processing

As a developer, you would program to a special interface. This interface isolates you from specific parsers and coding changes. SAX and DOM are language independent interfaces.
SAX and DOM have two different APIs to access the information from the XML parser. The different APIs use different approaches to access the information in the XML document.
SAX is a low level API and DOM is a high level API. The next sections will cover SAX and DOM in more detail.
XML applications will create a parser object, throw some XML at the parser and then process the results

Simple API for XML (SAX)
SAX is a standard interface for event based XML parsing.

SAX defines a number of events. It’s up to you to listen for them and respond to them.

The documents are accessed serially and an event is triggered at different parts of the document.

The common events are:
1.start of the document
2.start elements
3.characters
4.end elements
5.end of the document.

Basically you would write a program that has event handlers.

SAX is fast and has a low memory requirement.

SAX parsing is harder to setup.

Document Object Model (DOM)
Designed to be a portable interface for manipulating document structures.

Using DOM, the application builds a tree structure of the XML document in memory. The different parts of the XML file are stored in nodes in the DOM document. It then walks back and forth through the nodes in tree.
<?xml version=”1.0”?>
<resource>
<site>
<sitename>visualbuilder.com</sitename>
<emailaddress>webmaster@visualbuilder.com</emailaddress>
</site>
<site>
<sitename>activepace.com</sitename>
<emailaddress>info@activepace.com</emailaddress>
</site>
</resource>

Basics of programming using DOM
After you have made sure that your environment has been set up correctly (see Setting up the environment for XML and Java section), you may write your first Java and XML example.
For this example we will use the DOM API discussed in the previous section.
This is a simple example that will read the text “Hello World” from a xml file called “hello.xml”.
1) Import package org.w3c.dom

The Java interfaces have been defined by W3C and are contained in the package org.w3c.dom.

import org.w3c.dom.*;

2) Import Vendor dependent Parser.

The next step is to import a vendor dependent XML parser. In our case it will be the xerces DOM parser that we configured.
import org.apache.xerces.parsers.DOMParser;

0 comments

free counters
Your Ad Here

Cross Rates Powered by Forex Pros - The Forex Trading Portal.
java.sun.com jobs etisalat actress hot sex
Bangalore, 04 March 2008, UAE Telecoms Gaint founds ‘technologia’ in Bangalore to create continuous stream of new innovations. Affordable Website Design
Free Search Engine Submission
Free Search Engine Submission
Submit Your Site To The Web's Top 50 Search Engines for Free! BigDirectory.org - free url submission, online website directory National Directory Free Web Directory Submission - Dotster Directory Link Popularity Building
We offers advanced Link Popularity Services for small to large static, dynamic and eCommerce websites.
http://www.links-builder.com
India Search Engine and Web Directory Superblog Directory
HOT SEX,NUDE TECHNOLOGIAWORLD SQL JAVA SUN BEA IBM HCL SATYAM TCS CHIRANJEEVI CHIRU PAWAN HANSIKA SANGAVI SNEHA TAMIL SEX MALLU MASALA