Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

(DocumentBuilder).parse return null under jdk 1.5.0

843834Nov 24 2005 — edited Nov 25 2005
I would like to understand why the following code return a correct Document instance if it running under jdk 1.4.2 and instead return null if it running under jdk 1.5.0.

Thanks!
F.
import java.io.IOException;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

String test = "<root>" + "" + "</root>";
StringReader sreader = new StringReader (test);
InputSource is = new InputSource(sreader);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
builder = factory.newDocumentBuilder();
 
Document doc =  builder.parse(is);
 
System.out.println("Document is: " + doc);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 23 2005
Added on Nov 24 2005
2 comments
620 views