
How to use Java for reading XML dataUsing 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; 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.
IntelliJ Idea9 ActionScript 3/Flex Workflow Part 2 (O'Reilly Media) dot.Rory (BBC News) ExtenXLS 8 Java Spreadsheet SDK now with PDF Support (PRWeb via Yahoo! News)
|
Cisco
CCNA Certification Video Tutorial Guide - Learn How to Pass the Cisco
CCNA 640-802 Exam... Guaranteed!
| |||
|
| ||||