Created
January 29, 2018 14:44
-
-
Save jstutters/161185fa820a3a7fef6fabf255d48c50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.w3c.dom.Document; | |
import org.w3c.dom.Element; | |
import org.w3c.dom.NodeList; | |
import org.xml.sax.InputSource; | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import java.io.FileInputStream; | |
public class Main { | |
public static void main(String[] args) { | |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | |
try { | |
DocumentBuilder builder = factory.newDocumentBuilder(); | |
FileInputStream fis = new FileInputStream("/tmp/header.xml"); | |
InputSource is = new InputSource(fis); | |
Document doc = builder.parse(is); | |
Element element = doc.getDocumentElement(); | |
NodeList nodes = element.getChildNodes(); | |
for (int i = 0; i < nodes.getLength(); i++) { | |
System.out.println("" + nodes.item(i).getTextContent()); | |
} | |
} catch (Exception ex) { | |
ex.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment