xmlString to Document object converstion

View: New views
1 Messages — Rating Filter:   Alert me  

xmlString to Document object converstion

by Kisu San :: Rate this Message:

| View Threaded | Show Only this Message

Hi

I am using following code to convert String representation of xml to Document object. But it is not working.
Nor throwing any exception.

can anyone please help??



import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;



  public static Document stringToDom(String xmlSource) throws SAXException,
                        ParserConfigurationException, IOException {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                return builder.parse(new InputSource(new StringReader(xmlSource)));
        }