Knowledge
of the Document Object Model, XML, and Java is essential if you want
to work with the XML parsing. Classes like DocumentBuilderFactory and
the DocumentBuilder need to be used for creating the document object
in which you can load the XML document.
_______________________________________________
_______________________________________________
In the
program to parse XML document using Java, you have to import,
import
org.w3c.dom.Document;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
The above
classes need to be imported to work with XML parsing. The newDocumentBuilder()
method of the DocumentBuilderFactory object is used to create a DocumentBuilder
object. This DocumentBuilder object is used to load the XML file that
will be parsed.
Getting
all the nodes of the XML document by tag name can be done using the
method getElementByTagName(). These elements are stored in the NodeList
object which is navigated through a "for" loop and the elements
can be printed. Lots of example on parsing with an XML document this
way is available in the internet.
Linked by Thom Holwerda on Tue 3rd Oct 2006 22:09 UTC (OS News)
Sun Microsystems says its new UltraSparc T1 microprocessor, nicknamed Niagara, is creating a big splash . Sun was set to report Monday that 60 percent of the trial units of Niagara, an open-source product, have been ordered by new customers.