Java XML Parse String parse(String text)

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

Description

parse

License

Apache License

Declaration

static public Document parse(String text) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;

import org.w3c.dom.Document;

import org.xml.sax.InputSource;

public class Main {
    static public Exception exception = null;
    static private DocumentBuilder parser = null;

    static public Document parse(String text) {
        Document document = null;
        exception = null;/*from   www  .  j a v a  2s  .  c  om*/
        try {
            document = riskyParse(text);
        } catch (Exception e) {
            exception = e;
        }
        return document;
    }

    public static synchronized Document riskyParse(String text) throws Exception {
        InputSource is = new InputSource(new StringReader(text));
        return parser.parse(is);
    }
}

Related

  1. parse(String input)
  2. parse(String input, char delim, char esc)
  3. parse(String line)
  4. parse(String line)
  5. parse(String s)
  6. parse(String xml)
  7. parse(String xml)
  8. parse(String xml)
  9. parse(String xml)