package entity;

import java.io.*;
import javax.xml.parsers.DocumentBuilder; 
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

/**
 * @author ofuangka
 * DOMBuilder builds a DOM Document for StockXMLToDatabase to read
 *
 */
public class XMLParser {
	public static Document parseString(String s) {
		Document document = null;
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder builder = factory.newDocumentBuilder();
			document = builder.parse(new ByteArrayInputStream(s.getBytes()));
		}
		catch (Exception e) {
			System.err.println("Exception: " + e.toString());
		}
		return document;
	}
}
