Java XML Parse String parse(String xml)

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

Description

parse

License

Apache License

Declaration

public static Document parse(String xml) throws Exception 

Method Source Code


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

import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;

public class Main {
    public static Document parse(String xml) throws Exception {
        return newBuilder().parse(new InputSource(new StringReader(xml)));
    }/*from  www .  j  av a2s . c  o  m*/

    public static DocumentBuilder newBuilder() throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setIgnoringElementContentWhitespace(true);
        return dbf.newDocumentBuilder();
    }
}

Related

  1. parse(String text)
  2. parse(String xml)
  3. parse(String xml)
  4. parse(String xml)
  5. parse(String xml)
  6. parseAccessNumber(String line)
  7. parseAddressLines(String[] addressLines)
  8. parseArg(String arg)
  9. parseArgs(String text)