Method that provides an HTML parser for response configuration (uses JSoup).

@param config the chained configuration
@param fromServer the server response adapter
@return the parsed HTML content (a {@link Document} object)
330289
public static Object jsoupParse(final ChainedHttpConfig config, final FromServer fromServer) {
        try {
            return Jsoup.parse(fromServer.getInputStream(), fromServer.getCharset().name(), fromServer.getUri().toString());
        } catch (IOException e) {
            throw new TransportingException(e);
        }
    }
938496
private String getContentByContainer(
        CmsContainerElementBean element,
        CmsContainer container,
        CmsFormatterConfiguration configs) {

        String content = null;

        I_CmsFormatterBean formatter = getFormatterForContainer(
            m_cms,
            element,
            container,
            m_adeConfig,
            CmsADESessionCache.getCache(m_req, m_cms));
        if (formatter != null) {
            element = element.clone(); // clone element because presets for different containers may be different
            element.initSettings(m_cms, formatter, m_locale, m_req, container.getSettingPresets());
            try {
                content = getElementContent(element, m_cms.readResource(formatter.getJspStructureId()), container);
                //                }
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            if (content != null) {
                content = removeScriptTags(content);
            }
        }
        return content;
    }
1098186
public static Configuration loadFromString(String config)
    throws IOException, SAXException {
    ConfigurationImpl cfg = new ConfigurationImpl();

    XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(new ConfigHandler(cfg, null));
    Reader reader = new StringReader(config);
    parser.parse(new InputSource(reader));
    return cfg;
  }
169566
private void parseConfig(String config) {

        if (isValidConfig(config)) {
            String[] conf = config.split("x");
            if (conf[0].trim().equals("?")) {
                m_width = I_CmsFormatRestriction.DIMENSION_NOT_SET;
            } else {
                m_width = CmsClientStringUtil.parseInt(conf[0]);
                m_width = (m_width == 0) ? I_CmsFormatRestriction.DIMENSION_NOT_SET : m_width;
            }
            if (conf[1].trim().equals("?")) {
                m_height = I_CmsFormatRestriction.DIMENSION_NOT_SET;
            } else {
                m_height = CmsClientStringUtil.parseInt(conf[1]);
                m_height = (m_height == 0) ? I_CmsFormatRestriction.DIMENSION_NOT_SET : m_height;
            }
        }
    }
783706
public Serializable parseConfig (File source)
        throws IOException, SAXException
    {
        Digester digester = new Digester();
        Serializable config = createConfigObject();
        addRules(digester);
        digester.push(config);
        digester.parse(new FileInputStream(source));
        return config;
    }
60697
public static Map<String,List<ProtocolConfiguration>> parse(InputStream input) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false); // for now
        DocumentBuilder builder=factory.newDocumentBuilder();
        Document document=builder.parse(input);
        Element root=document.getDocumentElement();
        return parse(root);
    }
1140157
public static Document buildDocument(DocumentBuilder withBuilder,
                                         Reader fromReader) throws SAXException, IOException {
        return buildDocument(withBuilder, new InputSource(fromReader));
    }
816851
@Override
    protected Document convertToObject(HTTPResponse httpResponse)
    {
        //get response text
        Document document=null;
        String content=httpResponse.getContent();
        if(content!=null)
        {
            //get response encoding
            String encoding=this.getResponseDataEncoding();

            //create in memory stream
            byte[] data=IOHelper.convertStringToBinary(content,encoding);
            InputStream inputStream=new ByteArrayInputStream(data);

            try
            {
                //parse XML
                DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
                DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
                document=documentBuilder.parse(inputStream);
            }
            catch(Exception exception)
            {
                throw new FaxException("Unable to parse HTTP response text as XML.",exception);
            }
            finally
            {
                //'close' stream
                IOHelper.closeResource(inputStream);
            }
        }
        
        return document;
    }
918091
protected void createDocument() throws ParserConfigurationException
    {
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = builderFactory.newDocumentBuilder();
        DocumentType doctype = builder.getDOMImplementation().createDocumentType("html", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
        doc = builder.getDOMImplementation().createDocument("http://www.w3.org/1999/xhtml", "html", doctype);
        
        head = doc.createElement("head");
        Element meta = doc.createElement("meta");
        meta.setAttribute("http-equiv", "content-type");
        meta.setAttribute("content", "text/html;charset=utf-8");
        head.appendChild(meta);
        title = doc.createElement("title");
        title.setTextContent("PDF Document");
        head.appendChild(title);
        globalStyle = doc.createElement("style");
        globalStyle.setAttribute("type", "text/css");
        //globalStyle.setTextContent(createGlobalStyle());
        head.appendChild(globalStyle);
        
        body = doc.createElement("body");
        
        Element root = doc.getDocumentElement();
        root.appendChild(head);
        root.appendChild(body);
    }
327948
def _parse_website_config(self, (response, xml_bytes)):
        """"""
        root = XML(xml_bytes)
        index_suffix = root.findtext("IndexDocument/Suffix")
        error_key = root.findtext("ErrorDocument/Key")

        return WebsiteConfiguration(index_suffix, error_key)
1272028
public Document generate() throws ParserConfigurationException {
        final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        docFactory.setNamespaceAware(true);
        final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        this.doc = docBuilder.newDocument();
        doc.setXmlStandalone(true);

        // Create root <bom> node
        final Element bomNode = createRootElement("bom", null,
                new Attribute("xmlns", NS_BOM_11),
                new Attribute("version", String.valueOf(bom.getVersion())));
        if (bom.getSerialNumber() != null) {
            bomNode.setAttribute("serialNumber", bom.getSerialNumber());
        }

        final Element componentsNode = createElement(bomNode, "components");
        createComponentsNode(componentsNode, bom.getComponents());
        createExternalReferencesNode(bomNode, bom.getExternalReferences());
        return doc;
    }
73322
private String parseHtml(ClassLoader classLoader, String resName) throws IOException {
        InputStream is = classLoader.getResourceAsStream(resName);
        if (is == null)     return null;

        BufferedReader in = new BufferedReader(new InputStreamReader(is,UTF8));
        String line;
        StringBuilder buf = new StringBuilder();
        while((line=in.readLine())!=null) {
            Matcher m = HTML_INCLUDE.matcher(line);
            if(m.lookingAt())
                required.add(m.group(1));
            else
                buf.append(line).append('\n');
        }
        in.close();
        return buf.toString();
    }
124867
protected Document responseToDoc(String response){
        Document doc = null;
        try {
            DocumentBuilderFactory factory = new DocumentBuilderFactoryImpl();
            DocumentBuilderFactory.newInstance();
            DocumentBuilder builder =  factory.newDocumentBuilder();
            ByteArrayInputStream input =  new ByteArrayInputStream(response.getBytes("UTF-8"));
            doc = builder.parse(input);
        } catch (ParserConfigurationException e) {
            LOG.error("ParserConfigurationException", e);
        } catch (UnsupportedEncodingException e) {
            LOG.error("UnsupportedEncodingException", e);
        } catch (IOException e) {
            LOG.error("IOException", e);
        } catch (SAXException e) {
            LOG.error("SAXException", e);
        }

        return doc;
    }
48562
public static ServerConfiguration load(URL url) throws Exception
    {
        config = new ServerConfiguration();
        config.loadConfig(url);
        return config;
    }
1082057
String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
        byte[] filecontents = new byte[input.available()];
        try {
            DataInputStream dataIn = new DataInputStream(input);
            dataIn.readFully(filecontents);
        } finally {
            input.close();
        }
        String encoding = env.getEncoding();
        String rawDoc = (encoding!=null)
            ? new String(filecontents, encoding)
            : new String(filecontents);
        Pattern bodyPat = Pattern.compile("(?is).*<body\\b[^>]*>(.*)</body\\b.*");
        Matcher m = bodyPat.matcher(rawDoc);
        if (m.matches()) {
            return m.group(1);
        } else {
            String key = rawDoc.matches("(?is).*<body\\b.*")
                    ? "javadoc.End_body_missing_from_html_file"
                    : "javadoc.Body_missing_from_html_file";
            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null), key);
            return "";
        }
    }
393727
private void parseConfiguration(String config) {

        m_configuration = new HashMap<String, String>();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(config)) {
            for (String param : config.split(",")) {
                int index = param.indexOf("=");
                if ((index > 0) && (param.length() > (index + 1))) {
                    m_configuration.put(param.substring(0, index), param.substring(index + 1));
                }
            }
        }
    }
1076826
public static List<Node> parse(String html) {
    HtmlParser parser = new HtmlParser(html);
    return parser.parse();
  }