Horje
java code to get all leaf nodes of a xml Code Example
java code to get all leaf nodes of a xml
try {
  final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("input.xml");
  final XPathExpression xpath = XPathFactory.newInstance().newXPath().compile("//*[count(./*) = 0]");
  final NodeList nodeList = (NodeList) xpath.evaluate(doc, XPathConstants.NODESET);
  for(int i = 0; i < nodeList.getLength(); i++) {
    final Element el = (Element) nodeList.item(i);
    System.out.println(el.getNodeName());
  }
} catch (Exception e) {
  e.printStackTrace();
}




Java

Related
. Java Program to Delete the Specified Integer from an Array Code Example . Java Program to Delete the Specified Integer from an Array Code Example
java add forward / at the end of not present Code Example java add forward / at the end of not present Code Example
unparseable date android Code Example unparseable date android Code Example
set integer array value to null java Code Example set integer array value to null java Code Example
random number in java between 10 and 20 Code Example random number in java between 10 and 20 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9