programming-examples/java/XML/Read an Xml file.java

30 lines
685 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
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();
}
}
}