title: JAVA/SAX - Loss of characters using XML Parser
body: <p>I'm using <strong>SAX Parser</strong> to parse the XML file of RSS feeds on an Android App and sometimes the parsing of the pubDate of an item isn't completed (incomplete characters).</p>
  
  <p><strong>Ex:</strong></p>
  
  <p><strong>Actual PubDate</strong> Thu, 02 Apr 2015 12:23:41 +0000</p>
  
  <p><strong>PubDate Result of the parse:</strong> Thu,</p>
  
  <p>Here is the code that I'm using in the parser handler:</p>
  
  <pre><code>public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
          if ("item".equalsIgnoreCase(localName)) {
              currentItem = new RssItem(url);
          } else if ("title".equalsIgnoreCase(localName)) {
              parsingTitle = true;
          } else if ("link".equalsIgnoreCase(localName)) {
              parsingLink = true;
          } else if ("pubDate".equalsIgnoreCase(localName)) {
              parsingDate = true;
          }
      }
  
      @Override
      public void endElement(String uri, String localName, String qName) throws SAXException {
          if ("item".equalsIgnoreCase(localName)) {
              rssItems.add(currentItem);
              currentItem = null;
          } else if ("title".equalsIgnoreCase(localName)) {
              parsingTitle = false;
          } else if ("link".equalsIgnoreCase(localName)) {
              parsingLink = false;
          } else if ("pubDate".equalsIgnoreCase(localName)) {
              parsingDate = false;
          }
      }
  
      @Override
      public void characters(char[] ch, int start, int length) throws SAXException {
          if (parsingTitle) {
              if (currentItem != null) {
                  currentItem.setTitle(new String(ch, start, length));
                  parsingTitle = false;
              }
          } else if (parsingLink) {
              if (currentItem != null) {
                  currentItem.setLink(new String(ch, start, length));
                  parsingLink = false;
              }
          } else if (parsingDate) {
              if (currentItem != null) {
                  currentItem.setDate(new String(ch, start, length));
                  parsingDate = false;
              }
          }
      }
  </code></pre>
  
  <p>The loss of characters is pretty random, it happens in different XML items every time I run the app.</p>