Error creating new element.....

I am using following code with jdk 1.4 it is working correctly but with jdk1.5 it is not working:

DocumentBuilderFactory builderFactory =null;

DocumentBuilder builder =null;

Document doc =null;

try{

builderFactory = DocumentBuilderFactory.newInstance();

builder = builderFactory.newDocumentBuilder();

doc = builder.newDocument();// it is returning [#document: null]

Element formEle = doc.createElement("Output");//it is returning [Output: null]

}catch(Exception e){}

As per result of execution of this code at jdk1.4 should be in xml format. But in jdk1.5 because of null when i am appending any child and element. Its result is always [Output: null].

Please suggest me what i will do to remove this error.

Thanks......

[1160 byte] By [mkumar_upa] at [2007-11-26 19:27:33]
# 1

You are confusing the objects with their string representations that the toString() method returns, I believe. There is nothing wrong with the objects that your code produce, it's just that in Java 5 the toString() method returns the same as the getValue() method whereas in Java 1.4 the toString() method returned an XML representation of the object.

So what should you do? Stop using the toString() method to produce XML from the object and use the standard methods instead.

DrClapa at 2007-7-9 21:54:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...