【问题标题】:Add a meta tag using jsoup使用 jsoup 添加元标记
【发布时间】:2014-02-18 14:11:13
【问题描述】:

我想添加一个新的元标记

Document doc = Jsoup.parse(.....)
doc.select("meta").first.appendElement("meta".attr("name","henry").attr("content", "ford");

给我

<meta name="henry" content="ford" />
</meta>

没关系,但我怎样才能避免第二次

</meta> 

请。

【问题讨论】:

  • doc.select("meta").first().after("meta name=\"henry\" content=\"ford\" />");
  • 有效,但不如第一个整洁。

标签: jsoup


【解决方案1】:

你可以试试这个对我有用。

doc.head().appendElement("meta").attr("http-equiv","cache-control").attr("content","no-cache");

希望对你有帮助

编辑: 看起来您在“元” appendElement 语句之后缺少一个结束符。

【讨论】:

    猜你喜欢
    • 2016-10-02
    • 2013-05-29
    • 2014-05-30
    • 2011-03-02
    • 2011-11-27
    • 2020-08-20
    • 2011-10-27
    • 2019-08-30
    • 1970-01-01
    相关资源
    最近更新 更多