Using Java
API for XML Processing (JAXP) is the easiest way to work with the XML
files using Java. By using JAXP you can do anything with the XML document.
You can read it, change it and even remove the elements in it. You can
download the Java API for XML Processing from the Sun Microsystems website.
_______________________________________________
_______________________________________________
Once
you have installed that JAXP library you can include the necessary classes
in your Java program to gain access to the methods available for manipulating
the XML documents.
A typical
import statement in your Java program might include,
import
org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
After the
import is done you have to create a document object to load the XML
document that you want to work with. This document object is created
in three steps. First, you have to create a DocumentBuilderFactory object
and from that you have to create a DocumentBuilder and from that you
can create the Document object. A sample line of code that would load
the XML document might look like,
Document
doc = docbuilder.parse(new File("YourXmlFile.xml"));
You can
use methods like getElementsByTagName() to get all the elements that
have a particular name and use a 'for' loop or any other conditional
loops to navigate through them and manipulate them.
Current Newswire: (Linux Today)
"A few days ago, Walter Mossberg, writing in the Wall Street Journal, offered a verbal peek at the Mac user interface intended as heads-up for Windows XP users thinking of switching.
posted by Will Senn on Wed 30th Nov 2005 19:03 UTC (OS News)
This latest installment in the Core series from Prentice Hall PTR is a welcome arrival to the PHP/MySQL space. It is jam packed with useful information. At a little over 850 pages, this volume contains information on nearly every topic of interest in both the PHP and MySQL subject areas.
Officials to crack down on nude sunbathers (Moldova.org)
Police in southern California say they will buckle down on nude sunbathers on a popular clothing-optional beach at summer's end because of visitor complaints.San Onofre State Beach authorities said people who go nude on the beach after Labor Day will be ticketed for refusing to put clothes on, the Los Angeles Times reported Saturday.Times have changed. The population growth within a two-hour ...