Java tutorial
//package com.java2s; import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static String getValue(String xmlPath, String key) throws Exception { File file = new File(xmlPath); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(file); return doc.getElementsByTagName(key).item(0).getFirstChild().getNodeValue(); } }