how to get the attribute value of an xml node using java
I've an xml which looks like this: { <xml><ep><source type="xml">...</source><source type="text">..</source></ep></xml>} here i wanna retrieve the value of "source type" where type s an attribute. I 'd tried like this,But its not working: DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = domFactory.newDocumentBuilder(); Document dDoc = builder.parse("D:/workspace1/ereader/src/main/webapp/configurations/config.xml"); System.out.println(dDoc); XPath xPath = XPathFactory.newInstance().newXPath(); Node node = (Node) xPath.evaluate("//xml