code: public static Document toDocument(String xml) {
  		try {
  
  			DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
  					.newInstance();
  			documentBuilderFactory.setNamespaceAware(true);
  			documentBuilderFactory.setIgnoringElementContentWhitespace(true);
  			documentBuilderFactory.isIgnoringComments();
  			documentBuilderFactory.setCoalescing(true);
  
  			DocumentBuilder documentBuilder = documentBuilderFactory
  					.newDocumentBuilder();
  
  			InputSource inputSource = new InputSource();
  
  			inputSource.setCharacterStream(new StringReader(xml));
  
  			Document document = documentBuilder.parse(inputSource);
  
  			removeUnusedNamespaces(document);
  
  			return document;
  
  		} catch (ParserConfigurationException e) {
  			throw new RuntimeException(e);
  		} catch (SAXException e) {
  			throw new RuntimeException(e);
  		} catch (IOException e) {
  			throw new RuntimeException(e);
  		}
  	}
docs: Creates a Document from XML String
  
  @param xml
  The XML String
  @return The Document representation