Here you can find the source of documentFrom(String xml)
public static Document documentFrom(String xml) throws SAXException, IOException, ParserConfigurationException
/*//from ww w . j av a2 s. c om * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URL; import java.nio.ByteBuffer; import java.text.ParseException; import java.util.Date; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import com.amazonaws.AmazonClientException; public class Main{ private static DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); public static Document documentFrom(InputStream is) throws SAXException, IOException, ParserConfigurationException { is = new NamespaceRemovingInputStream(is); Document doc = factory.newDocumentBuilder().parse(is); is.close(); return doc; } public static Document documentFrom(String xml) throws SAXException, IOException, ParserConfigurationException { return documentFrom(new ByteArrayInputStream(xml.getBytes())); } public static Document documentFrom(URL url) throws SAXException, IOException, ParserConfigurationException { return documentFrom(url.openStream()); } }