import java.io.*;
import javax.xml.parsers.*;
import java.io.File;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.File;
public class Util {
public static void main(String[] args) {
File inputFile = new File("input.txt");
System.out.println("get root element of xml");
root(xml) ;
}
public static void root(File inputFile)
throws SAXException, ParserConfigurationException, IOException {
// Parse the given input
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputFile);
System.out.println("Root element in xml is:"+doc.getDocumentElement());
}
}
If you have filr instead of xml string,
make your xml structure
save it to
No comments:
Post a Comment