Skip to content

Instantly share code, notes, and snippets.

@max747
Created September 7, 2011 07:31
Show Gist options
  • Save max747/1199976 to your computer and use it in GitHub Desktop.
Save max747/1199976 to your computer and use it in GitHub Desktop.
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.junit.Test;
public class Dom4jTest {
@Test
public void readXml() throws IOException, DocumentException {
SAXReader reader = new SAXReader();
InputStreamReader stream = new InputStreamReader(new FileInputStream(new File("messages_ja.xml")));
Document document = reader.read(stream);
Node messageNode = document.selectSingleNode("/MessageCollection/BugPattern[@type='IL_INFINITE_LOOP']");
Node longDesc = messageNode.selectSingleNode("LongDescription");
System.out.println(longDesc.getText());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment