Java XML Document Parse parseDocument(String documentString)

Here you can find the source of parseDocument(String documentString)

Description

parse Document

License

Open Source License

Declaration

@SuppressWarnings({ "ProhibitedExceptionDeclared" })
    public static Document parseDocument(String documentString) throws Exception 

Method Source Code


//package com.java2s;
/*//  www .  j a v a 2s .  co  m
 * SafeOnline project.
 *
 * Copyright 2006 Lin.k N.V. All rights reserved.
 * Lin.k N.V. proprietary/confidential. Use is subject to license terms.
 */

import java.io.*;
import javax.xml.parsers.*;

import org.w3c.dom.Document;

import org.xml.sax.InputSource;

public class Main {
    @SuppressWarnings({ "ProhibitedExceptionDeclared" })
    public static Document parseDocument(String documentString) throws Exception {

        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(true);
        DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
        StringReader stringReader = new StringReader(documentString);
        InputSource inputSource = new InputSource(stringReader);
        return domBuilder.parse(inputSource);
    }
}

Related

  1. parseDocument(InputStream is)
  2. parseDocument(InputStream is)
  3. parseDocument(Path xmlPath)
  4. parseDocument(Reader reader)
  5. parseDocument(String docText)
  6. parseDocument(String documentString)
  7. parseDocument(String path)
  8. parseDocument(String xmlString)
  9. parseDocumentIntoStringXML(Document document)