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!

String to org.w3c.dom.Document conversion problem

843834Nov 30 2009 — edited Nov 30 2009
Hi all

I am using JDK 5 and am having scenario to convert String to w3c.Document object , by the way of finding solution i got a code snippet in sun forum

final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DATA>sample</DATA>"; // xml to convert
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.parse(new InputSource(new StringReader(xml)));
System.out.println(document);

But when i try to execute this code , am gettng output as null. , i dont know why this code behaving like that , can you please help me to solve the problem?

Thanks
Prabu.P
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 28 2009
Added on Nov 30 2009
1 comment
183 views