попробуйте следующее решение,
public class DomParser {
public static void main(String[] args) {
try {
File inputFile = new File("Test.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document document = dBuilder.parse(inputFile);
document.getDocumentElement().normalize();
NodeList nodeList = document.getElementsByTagName("Property");
for (int temp = 0; temp < nodeList.getLength(); temp++) {
Node node = nodeList.item(temp);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
System.out.println("Property (FormalName) : " + element.getAttribute("FormalName") +
", Value : " + element.getAttribute("Value"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
вывод,
Property (FormalName) : CategoryKeywords, Value : Photo/Multimedia
Property (FormalName) : CountryKeywords, Value : UK
Property (FormalName) : RegKeywrd, Value : Europe
Property (FormalName) : Ticker Symbol, Value : ABC
Property (FormalName) : Exchange, Value : London