Creating
a simple Java XML DOM
Creating
a simple Java XML Document Object Model is very easy if you use the appropriate
imports and use the appropriate classes and methods. The following import
statements are to be used to use the appropriate classes and methods to
work with the XML document.
_______________________________________________
_______________________________________________
import
org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
Creating
a document object that can load the XML document involves three steps,
and the following code will give you an idea on how to create such a document
object.
DocumentBuilderFactory
dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse (new File("ur_xml_file.xml"));
Once you
have created the document object, there are methods available in the document
object to work with the XML document. The method getDocumentElement().getNodeName()
can be used to get the root element name of the XML document that is loaded
in the document object.
The getElementsByTagName()
method can be used to get all the names of the elements that is specified
as an string argument to that method.Lots of complete code samples are
available in the internet that uses these methods to work with the XML
document.
eValid Supports Regular Expressions Analysis of Web Pages (PRWeb via Yahoo! News) Functional testing of web applications now has a new degree of generality with the introduction of Regular Expression processing in the eValid suite. Related Articles (OS News) Trolltech was very kind to send us over a copy of the recently released " C++ GUI Programming with Qt 3 " book, part of "Bruce Perens' Open Source Series". The book weighs in at about 400 pages and comes with a CD-ROM loaded with software not found elsewhere freely. 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.
FREE
Subscription
Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
Note
: We never rent, trade, or sell my email lists to
anyone.
We assure that your privacy is respected
and protected.
_______________________________________
Recommended
XML Books
|
|