title: Convert a String to w3c.dom.Element: XMLParseException:Start of root element expected
body: <p>I found the following piece of code from a blog, when running it I get an exception </p>
  
  <blockquote>
    <p>XMLParseException:Start of root element expected. at 9th line.</p>
  </blockquote>
  
  <p>Can any one explain why I get the Exception and suggest any other way for converting String to an element?</p>
  
  <pre><code>String s = "Hello DOM Parser";
  java.io.InputStream sbis = new java.io.StringBufferInputStream(s);
  javax.xml.parsers.DocumentBuilderFactory b = javax.xml.parsers.DocumentBuilderFactory.newInstance();
  b.setNamespaceAware(false);
  org.w3c.dom.Document doc = null;
  javax.xml.parsers.DocumentBuilder db = null;
  db = b.newDocumentBuilder();
  doc = db.parse(sbis);     
  
  org.w3c.dom.Element e = doc.getDocumentElement();
  </code></pre>