title: Current Event of an XMLEventReader
body: <p>From <a href="http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLEventReader.html#getElementText%28%29" rel="nofollow">XMLEventReader</a>:</p>
  
  <pre><code>String getElementText()
  Reads the content of a text-only element. 
  Precondition: the current event is START_ELEMENT.
  Postcondition: the current event is the corresponding END_ELEMENT.
  </code></pre>
  
  <p>What is the "current" event of an <code>XMLEventReader</code>, being referred here?</p>
  
  <p>Is it the event that was returned by the last call for that reader:</p>
  
  <p>a) to <code>nextEvent()</code>, or<br>
  b) to <code>peek()</code>?</p>
  
  <p>From the answer of the previous question, how do you interpret this snippet from listing 2 of <a href="http://www.ibm.com/developerworks/xml/library/x-stax2/index.html" rel="nofollow">StAX'ing up XML</a>:</p>
  
  <pre><code>while (reader.hasNext()) {
      XMLEvent event = reader.peek();
      if (event.isStartElement()) {
          StartElement start = event.asStartElement();
          if (ICON.equals(start.getName())) {
              System.out.println(reader.getElementText());
              break;
          }
      }
      reader.nextEvent();
  }
  </code></pre>
  
  <p>I'm encountering a <code>ParseError: parser must be on START_ELEMENT to read next text</code>.</p>