title: How to get xml output of text for stanford corenlp
body: <p>I've been reading the API and the documentation trying to find an answer, but haven't gotten close to solving the problem.</p>
  
  <p>I want to take a bunch of sentences and get the output as XML for all the sentences:</p>
  
  <pre><code>      &lt;token id="1"&gt; 
          &lt;word&gt;That&lt;/word&gt; 
          &lt;lemma&gt;that&lt;/lemma&gt; 
          &lt;CharacterOffsetBegin&gt;0&lt;/CharacterOffsetBegin&gt; 
          &lt;CharacterOffsetEnd&gt;4&lt;/CharacterOffsetEnd&gt; 
          &lt;POS&gt;DT&lt;/POS&gt; 
          &lt;NER&gt;O&lt;/NER&gt; 
        &lt;/token&gt; 
  </code></pre>
  
  <p>I only managed to figure out how to get the tree parsed, but that's not helpful to the thing I want to build. Anyways, here's the code I'm using right now:</p>
  
  <pre><code>Properties props = new Properties();
  props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
  StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
  
  // read some text in the text variable
  String text = "We won the game."; // Add your text here!
  
  // create an empty Annotation just with the given text
  Annotation document = new Annotation(text);
  
  // run all Annotators on this text
  pipeline.annotate(document);
  
  // these are all the sentences in this document
  // a CoreMap is essentially a Map that uses class objects as keys and has values with custom types
  List&lt;CoreMap&gt; sentences = document.get(SentencesAnnotation.class);
  
  for(CoreMap sentence: sentences) {
  
    // this is the parse tree of the current sentence
    Tree tree = sentence.get(TreeAnnotation.class);
  
    // this is the Stanford dependency graph of the current sentence
    SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
  }
  </code></pre>
  
  <p>I'm using the code in the documentation. </p>