把一个XML字符串转换为一个XML文档对象

/***
* 把一个XML字符串转换一个XML文档对象
* @param returnXML : XML字符串
* @return Document xml文档对象
* @throws Exception
*/
private org.w3c.dom.Document getDocument(String returnXML) throws BOException
{
org.w3c.dom.Document doc = null;
if (returnXML != null && returnXML.length() > 0)
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = null;
try
{
db = dbf.newDocumentBuilder();
}
catch (ParserConfigurationException pce)
{
pce.printstacktrace();
}
try
{
StringReader rd = new StringReader(returnXML);
InputSource in = new InputSource(rd);
doc = db.parse(in);

} catch (IOException ioe) { ioe.printstacktrace(); } catch (SAXException saxe) { saxe.printstacktrace(); } } return doc; }

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念