Tuesday, January 24, 2012

How can I get it to parse XML contained within a String instead of a file?

 public static Document loadXMLFromString(String xml) throws Exception
    {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(xml));
        return builder.parse(is);
    }


No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Podman: The Complete Guide to Rootless, Daemonless Containers

Podman: The Complete Guide to Rootless, Daemonless Containers Podman is an open-source container engine designed to build, run, manage, and...