Here you can find the source of parseXMLDocument(String xmlResponse)
Parameter | Description |
---|---|
xmlResponse | XML String representation |
Parameter | Description |
---|
public static org.w3c.dom.Document parseXMLDocument(String xmlResponse) throws ParserConfigurationException, IOException, SAXException
//package com.java2s; //License from project: Apache License import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.StringReader; public class Main { /**//from w w w . ja v a2 s . c o m * Parses XML String * @param xmlResponse XML String representation * @return Parsed XML Document * @throws javax.xml.parsers.ParserConfigurationException * @throws java.io.IOException * @throws org.xml.sax.SAXException */ public static org.w3c.dom.Document parseXMLDocument(String xmlResponse) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(xmlResponse)); return builder.parse(is); } }