Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Element; import org.xml.sax.SAXException; public class Main { /** * Obtiene el nodo raiz del documento xml * * @param respuestaPost * @return * @throws ParserConfigurationException * @throws IOException * @throws SAXException */ public static Element getRootElement(final String respuestaPost) throws ParserConfigurationException, IOException, SAXException { return DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(respuestaPost.getBytes())).getDocumentElement(); } }