当前位置: 首页>>代码示例>>Java>>正文


Java Element.removeAttr方法代码示例

本文整理汇总了Java中org.jsoup.nodes.Element.removeAttr方法的典型用法代码示例。如果您正苦于以下问题:Java Element.removeAttr方法的具体用法?Java Element.removeAttr怎么用?Java Element.removeAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jsoup.nodes.Element的用法示例。


在下文中一共展示了Element.removeAttr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUpdatedFileContent

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getUpdatedFileContent(List<Vacancy> vacancies) {

        Document document = null;
        try {
            document = getDocument();

            Element templateOriginal = document.getElementsByClass("template").first();
            Element copyTemplate = templateOriginal.clone();
            copyTemplate.removeAttr("style");
            copyTemplate.removeClass("template");
            document.select("tr[class=vacancy]").remove().not("tr[class=vacancy template");

            for (Vacancy vacancy : vacancies) {
                Element localClone = copyTemplate.clone();
                localClone.getElementsByClass("city").first().text(vacancy.getCity());
                localClone.getElementsByClass("companyName").first().text(vacancy.getCompanyName());
                localClone.getElementsByClass("salary").first().text(vacancy.getSalary());
                Element link =localClone.getElementsByTag("a").first();
                link.text(vacancy.getTitle());
                link.attr("href", vacancy.getUrl());

                templateOriginal.before(localClone.outerHtml());
            }
        } catch (IOException e) {
            e.printStackTrace();
            return "Some exception occurred";
        }
        return document.html();
    }
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:30,代码来源:HtmlView.java

示例2: ifDevelopment

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void ifDevelopment(Element element){

        String attrValue = element.attr(IF_DEV_ATTR);
        element.removeAttr(IF_DEV_ATTR);
        boolean keepElement = true;

        if(attrValue.equalsIgnoreCase("false"))
            keepElement = false;

        //Remove element if NOT in DEVELOPMENT_MODE
        if(keepElement&&!app.underDevelopment())
            element.remove();


        //Remove element if in DEVELOPMENT_MODE
        if(!keepElement&&app.underDevelopment())
            element.remove();

    }
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:20,代码来源:IfDevTrasformer.java

示例3: url2xhtml

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
 * 将页面转为{@link org.jsoup.nodes.Document}对象,xhtml 格式
 *
 * @param url
 * @return
 * @throws Exception
 */
protected Document url2xhtml(String url) throws Exception {
    Document doc = Jsoup.connect(url).get(); //获得

    if (logger.isDebugEnabled()) {
        logger.debug("baseUri: {}", doc.baseUri());
    }

    for (Element script : doc.getElementsByTag("script")) { //除去所有 script
        script.remove();
    }

    for (Element a : doc.getElementsByTag("a")) { //除去 a 的 onclick,href 属性
        a.removeAttr("onclick");
        a.removeAttr("href");
    }

    Elements links = doc.getElementsByTag("link"); //将link中的地址替换为绝对地址
    for (Element element : links) {
        String href = element.absUrl("href");

        if (logger.isDebugEnabled()) {
            logger.debug("href: {} -> {}", element.attr("href"), href);
        }

        element.attr("href", href);
    }

    doc.outputSettings()
            .syntax(Document.OutputSettings.Syntax.xml)
            .escapeMode(Entities.EscapeMode.xhtml);  //转为 xhtml 格式

    if (logger.isDebugEnabled()) {
        String[] split = doc.html().split("\n");
        for (int c = 0; c < split.length; c++) {
            logger.debug("line {}:\t{}", c + 1, split[c]);
        }
    }
    return doc;
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:47,代码来源:HtmlConverter.java

示例4: removeUselessAttributes

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static void removeUselessAttributes(Element element) {
    for (Element child : element.getAllElements()) {
        if (child.hasAttr("style"))
            child.removeAttr("style");
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:7,代码来源:HtmlUtils.java

示例5: modifyBootstrapPage

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void modifyBootstrapPage(final BootstrapPageResponse response) {

    response.getDocument().child(0).attr("lang", "de");

    final Element head = response.getDocument().head();

    head.getElementsByAttributeValueContaining("http-equiv", "X-UA-Compatible").remove();

    head.appendElement("meta").attr("name", "viewport").attr("content", "width=device-width, initial-scale=1, shrink-to-fit=no");
    head.appendElement("link").attr("rel", "stylesheet").attr("href", "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css");

    final Element body = response.getDocument().body();
    body.removeAttr("scroll");

    //     body.append("<script src=\"./VAADIN/themes/mytheme/js/jquery-3.2.1.slim.min.js\"</script>");
    // https://v4-alpha.getbootstrap.com/components/tooltips/
    //   body.append("<script src=\"./VAADIN/themes/mytheme/js/tether-1.4.0.js\"</script>");
    // body.append("<script src=\"./VAADIN/themes/mytheme/bootstrap/js/bootstrap.min.js\"</script>");
    //  body.append("<script src=\"" + contextPath + "/VAADIN/themes/map-bootstrap/vendor/bootstrap/js/bootstrap.min.js\"></script>");
    //  body.append("<script src=\"" + contextPath + "/VAADIN/themes/map-bootstrap/vendor/material-design/js/arrive.min.js\"></script>");
    //  body.append("<script src=\"" + contextPath + "/VAADIN/themes/map-bootstrap/vendor/material-design/js/material.min.js\"></script>");
    //  body.append("<script src=\"" + contextPath + "/VAADIN/themes/map-bootstrap/vendor/material-design/js/ripples.min.js\"></script>");
    //  body.append("<script>$.material.init();</script>");
    //  body.append("<div id=\"map-alerts\" class=\"sr-only\" aria-atomic=\"true\" aria-live=\"assertive\" role=\"alert\"></div>");
}
 
开发者ID:knoobie,项目名称:bootstrap-formgroup,代码行数:30,代码来源:MySessionListener.java


注:本文中的org.jsoup.nodes.Element.removeAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。