Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private static String readXsdVersionFromFile(Document doc) { final String JBOSS_ESB = "jbossesb"; NodeList nodes = doc.getChildNodes(); if (nodes != null) { for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (JBOSS_ESB.equals(node.getNodeName())) { NamedNodeMap attributes = node.getAttributes(); for (int j = 0; j < attributes.getLength(); j++) { Node attribute = attributes.item(j); if ("xmlns".equals(attribute.getNodeName())) { String value = attribute.getNodeValue(); if (value.contains(JBOSS_ESB) && value.endsWith(".xsd")) return value.substring(value.lastIndexOf('/') + 1, value.length()); else throw new IllegalStateException( "The ESB descriptor points to an invalid XSD" + value); } } } } throw new IllegalArgumentException("No root node " + JBOSS_ESB + " found."); } else throw new IllegalArgumentException("Descriptor has no root element !"); } }