You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
685 B
Java

Read an Xml file
package com.ack.xml.jdom;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class ReadAnXmlFile {
public static void main( String[] args ) {
try {
// use SAXBuilder to create DOM from numerous types of input
SAXBuilder builder = new SAXBuilder();
// expand entities within the SAXBuilder
builder.setExpandEntities( true );
// SAXBuilder is more does create the entire DOM at once
Document doc = builder.build( "drainpipe.xml" );
System.out.println( doc );
}
catch( JDOMException e ) {
e.printStackTrace();
}
}
}