Java tutorial
//package com.java2s; import org.w3c.dom.*; public class Main { private static String getTextValue(String def, Element doc, String tag) { String value = def; NodeList noteList = doc.getElementsByTagName(tag); if (noteList.getLength() > 0) { for (int i = 0; i < noteList.getLength(); i++) { Node note = noteList.item(i); Element noteElement = (Element) note; if (noteElement.getNodeType() == Node.ELEMENT_NODE) { if (noteElement.getElementsByTagName("pitch").getLength() > 0) { Element pitchElement = (Element) noteElement.getElementsByTagName("pitch").item(0); System.out.println("Staff idX : " + pitchElement.getElementsByTagName("step").item(0).getTextContent()); } else { System.out.println("yoktir"); } } else { System.out.println("not element"); } } // value = nl.item(0).getFirstChild().getNodeValue(); } return value; } }