import java.io.File;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class MainClass {
public static void main(String[] args) throws Exception{
String characterName ="asdf";
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new File("r.xml"));
List actList = document.getRootElement().getChildren("ACT");
allDone: for (int act = 0; act < actList.size(); act++) {
List sceneList = ((Element) actList.get(act)).getChildren("SCENE");
for (int scene = 0; scene < sceneList.size(); scene++) {
List speechList = ((Element) sceneList.get(scene)).getChildren("SPEECH");
for (int speech = 0; speech < speechList.size(); speech++) {
if (characterName.equalsIgnoreCase(((Element) speechList.get(speech))
.getChildText("SPEAKER"))) {
System.out.println(characterName);
break allDone;
}
}
}
}
}
}
|