1 DocumentBuilderFactory docBuilderFactory = null;
2 DocumentBuilder docBuilder = null;
3 Document doc = null;
4 docBuilderFactory = DocumentBuilderFactory.newInstance();
5 docBuilder = docBuilderFactory.newDocumentBuilder();
6 InputStream inputStream = new ByteArrayInputStream(xml.getBytes());//xml为要解析的字符串
7 doc = docBuilder.parse(inputStream);