title: null pointer exception using SAX XML Parser
body: <p>I am using the SAX Parser for XML Parsing. The problem is if I print, everything is fine. However, If I want to save anything, I get this error message (with the typos):</p>
  
  <pre><code>"XML Pasing Excpetion = java.lang.NullPointerException" 
  </code></pre>
  
  <p>My code is given below:</p>
  
  <p>Parser code:</p>
  
  <pre><code>try {
          /** Handling XML */
          SAXParserFactory spf = SAXParserFactory.newInstance();
          SAXParser sp = spf.newSAXParser();
          XMLReader xr = sp.getXMLReader();
  
          /** Send URL to parse XML Tags */
          URL sourceUrl = new URL(
          "http://50.19.125.224/Demo/VeryGoodSex_and_the_City_S6E6.xml");
  
          /** Create handler to handle XML Tags ( extends DefaultHandler ) */
          MyXMLHandler myXMLHandler = new MyXMLHandler();
          xr.setContentHandler((ContentHandler) myXMLHandler);
          xr.parse(new InputSource(sourceUrl.openStream()));
  
      } catch (Exception e) {
          System.out.println("XML Pasing Excpetion = " + e);
      }
  </code></pre>
  
  <p>Object to hold XML parsed Info:</p>
  
  <pre><code>public class ParserObject {
  
  String name=null;
  String description=null;
  String bitly=null; //single
  String productLink=null;//single
  String productPrice=null;//single
  Vector&lt;String&gt; price=null;
  }
  </code></pre>
  
  <p>Handler class:</p>
  
  <pre><code>static ParserObject[] xmlDataObject = null;
  
  public void endElement(String uri, String localName, String qName)
  throws SAXException {
  
  
      currentElement = false;
  
  
      if (qName.equalsIgnoreCase("title"))
      {
          xmlDataObject[index].name=currentValue;
      }
  
      else if (qName.equalsIgnoreCase("artist"))
      {
          xmlDataObject[index].artist=currentValue;
      } 
  
  }
  
  
  public void startElement(String uri, String localName, String qName,
  Attributes attributes) throws SAXException {
  
  
      currentElement = true;
  
      if (qName.equalsIgnoreCase("allinfo"))
      {
          System.out.println("started");
      }
  
      else if (qName.equalsIgnoreCase("tags"))
      {
          insideTag=1;
      } 
  
  }
  
  public void characters(char[] ch, int start, int length)
  throws SAXException {
  
      if (currentElement) {
          currentValue = new String(ch, start, length);
          currentElement = false;
      }
  
  }
  </code></pre>