
Using java to process XML - sample codeProcessing XML document using the Java code is simple if you know the logic and the classes and the methods that are used in it. A document object is created to load the XML file that you want to process. The following code sample would do that,
_______________________________________________ import
org.w3c.dom.Document; DocumentBuilderFactory
dbf = DocumentBuilderFactory.newInstance(); The above code could be understood if you see how the document object is created and the XML file you want to process is loaded into that document object. Once the XML document is loaded you can use the getDocumentElement().getNodeName() to get the name of the root element. You can create a NodeList object and get all the nodes by Tagname using the method getElementsByTagName(). This method takes the name of the element that you want as the argument in the form of string. You can loop through the NodeList object using a 'for' loop and work with the elements.
SpringSource Springs Enterprise Tomcat Server (InformationWeek) MapQuest Engages Developer Community with Presence at SXSW; Shows Easy-to-Use, Developer Friendly Tools (Business Wire via Yahoo! Finance)
|
Cisco
CCNA Certification Video Tutorial Guide - Learn How to Pass the Cisco
CCNA 640-802 Exam... Guaranteed!
| |||
|
| ||||