Android StringReader Create stringToXml(final String data)

Here you can find the source of stringToXml(final String data)

Description

string To Xml

Declaration

public static Document stringToXml(final String data) 

Method Source Code

//package com.java2s;
import java.io.Reader;
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilderFactory;

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

public class Main {
    public static Document stringToXml(final String data) {

        try {//from   w ww. j a va2  s. co m
            final Reader reader = new StringReader(data);
            final InputSource source = new InputSource(reader);

            return DocumentBuilderFactory.newInstance()
                    .newDocumentBuilder().parse(source);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}