Java XML Document from String loadXMLFromString(String xml)

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

Description

load XML From String

License

LGPL

Declaration

public static Document loadXMLFromString(String xml) throws Exception 

Method Source Code

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

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 loadXMLFromString(String xml) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(xml));
        return builder.parse(is);
    }/*from  w w w . j  av  a  2s.  com*/
}

Related

  1. getXMLDocument(final String xml)
  2. loadDocument(String documentContent)
  3. loadDocument(String xmlString)
  4. loadXml(String xml)
  5. loadXMLFrom(String xml)
  6. loadXMLFromString(String xml)
  7. loadXMLFromString(String xml)
  8. readString(String xml)