Source Code : JDom: Locating a speech with the findCharactersFirstSpeech() method

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

JDom: Locating a speech with the findCharactersFirstSpeech() method

   


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;
            }
          }
        }
      }
  }
}

   
    
  

Thank with us