Java XML Document Parse parse(String document)

Here you can find the source of parse(String document)

Description

parse

License

Open Source License

Declaration

public static Document parse(String document) throws SAXException, IOException 

Method Source Code


//package com.java2s;
// modify it under the terms of the GNU General Public License

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;

import org.w3c.dom.Document;

import org.xml.sax.SAXException;

public class Main {
    private static DocumentBuilder builder = null;

    public static Document parse(java.io.InputStream in) throws SAXException, IOException {
        Document result = null;/*  w  w  w  . ja  v a 2  s.  co  m*/
        synchronized (builder) {
            result = builder.parse(in);
        }
        return result;
    }

    public static Document parse(String document) throws SAXException, IOException {
        return parse(new ByteArrayInputStream(document.getBytes()));
    }
}

Related

  1. parse(final DocumentBuilder documentBuilder, final File pomFile)
  2. parseDocument(byte[] bytes)
  3. parseDocument(File f)
  4. parseDocument(File file)
  5. parseDocument(InputSource is)