title: Xml not parsing String as input with sax
body: <p>I have a string input from which I need to extract simple information, here is the sample xml (from mkyong):</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;company&gt;
      &lt;staff&gt;
          &lt;firstname&gt;yong&lt;/firstname&gt;
          &lt;lastname&gt;mook kim&lt;/lastname&gt;
          &lt;nickname&gt;mkyong&lt;/nickname&gt;
          &lt;salary&gt;100000&lt;/salary&gt;
      &lt;/staff&gt;
      &lt;staff&gt;
          &lt;firstname&gt;low&lt;/firstname&gt;
          &lt;lastname&gt;yin fong&lt;/lastname&gt;
          &lt;nickname&gt;fong fong&lt;/nickname&gt;
          &lt;salary&gt;200000&lt;/salary&gt;
      &lt;/staff&gt;
  &lt;/company&gt;
  </code></pre>
  
  <p>How I parse it within my code (I have a field <code>String name</code> in my class) :</p>
  
  <pre><code>public String getNameFromXml(String xml) {
          try {
  
              SAXParserFactory factory = SAXParserFactory.newInstance();
              SAXParser saxParser = factory.newSAXParser();
              DefaultHandler handler = new DefaultHandler() {
  
                  boolean firstName = false;
  
                  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
  
                      if (qName.equalsIgnoreCase("firstname")) {
                          firstName = true;
                      }
                  }
  
                  public void characters(char ch[], int start, int length) throws SAXException {
  
                      if (firstName) {
                          name = new String(ch, start, length);
                          System.out.println("First name is : " + name);
                          firstName = false;
                      }
  
                  }
  
              };
  
              saxParser.parse(xml.toString(), handler);
  
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          return name;
      }
  </code></pre>
  
  <p>I'm getting a <code>java.io.FileNotFoundException</code> and I see that it's trying to find a file <code>myprojectpath + the entireStringXML</code></p>
  
  <p>What am I doing wrong?</p>
  
  <p>Addon :</p>
  
  <p>Here is my main method :</p>
  
  <pre><code>public static void main(String[] args) {
          Text tst = new Text("&lt;?xml version=\"1.0\"?&gt;&lt;company&gt;   &lt;staff&gt;     &lt;firstname&gt;yong&lt;/firstname&gt;     &lt;lastname&gt;mook kim&lt;/lastname&gt;       &lt;nickname&gt;mkyong&lt;/nickname&gt;     &lt;salary&gt;100000&lt;/salary&gt; &lt;/staff&gt;    &lt;staff&gt;     &lt;firstname&gt;low&lt;/firstname&gt;      &lt;lastname&gt;yin fong&lt;/lastname&gt;       &lt;nickname&gt;fong fong&lt;/nickname&gt;      &lt;salary&gt;200000&lt;/salary&gt; &lt;/staff&gt;&lt;/company&gt;");
          NameFilter cc = new NameFilter();
          String result = cc.getNameFromXml(tst);
          System.out.println(result);
      }
  </code></pre>