Android XML Parse parse(String source)

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

Description

parse

Declaration

public static Document parse(String source)
            throws ParserConfigurationException, SAXException, IOException 

Method Source Code

//package com.java2s;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

import org.xml.sax.SAXException;

public class Main {
    public static Document parse(String source)
            throws ParserConfigurationException, SAXException, IOException {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();/*from w  w  w.ja  v a  2s  .  com*/
        return builder.parse(new ByteArrayInputStream(source.getBytes()));
    }

    public static Document parse(File source)
            throws ParserConfigurationException, SAXException, IOException {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
        return builder.parse(source);
    }
}

Related

  1. parse(File source)
  2. parse(String xml)
  3. parse(String xmlstr, Class clazz, List fields, List elements, String itemElement)
  4. parseResponse(HttpResponse response)
  5. parseTagValue(String xml, String tag, String endTag)