Here you can find the source of getXmlDocument(final String container)
Parameter | Description |
---|---|
container | a parameter |
Parameter | Description |
---|---|
SAXException | an exception |
public static Document getXmlDocument(final String container) throws Exception
//package com.java2s; /*// ww w . j av a 2 s .co m * Fast Code Plugin for Eclipse * * Copyright (C) 2008 Gautam Dev * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Plugin Home Page: http://fast-code.sourceforge.net/ */ import java.io.ByteArrayInputStream; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /** * * @param container * @return * @throws SAXException */ public static Document getXmlDocument(final String container) throws Exception { final InputStream inputStream = new ByteArrayInputStream(container.getBytes()); final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(inputStream); } }