Android XML Document Load getDocument(String strxml)

Here you can find the source of getDocument(String strxml)

Description

get Document

Declaration

public static Document getDocument(String strxml) 

Method Source Code

//package com.java2s;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

import org.xml.sax.InputSource;
import android.util.Log;

public class Main {

    public static Document getDocument(String strxml) {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();/*from  w  ww . j  a  v a  2s. c o m*/
        try {
            DocumentBuilder builder = factory.newDocumentBuilder();
            strxml = new String(strxml.getBytes(), "UTF-8");
            StringReader stringReader = new StringReader(strxml);
            InputSource inputSource = new InputSource(stringReader);
            Document document = builder.parse(inputSource);
            return document;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. documentFrom(InputStream is)
  2. documentFrom(String xml)
  3. documentFrom(URL url)
  4. URLToDocument(URL url)
  5. getDocument(String strxml)
  6. loadXMLFromString(String xml)
  7. load(String filename)
  8. loadData(String xmlData)