问答详情
源自:5-3 JDOM 设置 XML 格式

关于转义, 不会用。。。

static java.lang.String    escapeAttribute(EscapeStrategy strategy, java.lang.String value)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) as well as CR/NL, tabs, and Quote characters which require escaping inside Attribute values and converts their character representation to the appropriate entity reference suitable for XML attribute content.

   

static java.lang.String    escapeText(EscapeStrategy strategy, java.lang.String eol, java.lang.String value)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.

   

Format    setEscapeStrategy(EscapeStrategy strategy)

Sets the EscapeStrategy to use for character escaping.

   http://www.jdom.org/docs/apidocs/org/jdom2/output/Format.html


提问者:风中过客 2015-06-11 23:11

个回答

  • 李阿昀
    2015-07-26 20:38:24

    以上真的是在胡说八道!不知道为什么弄不出来,还来混淆视听!

  • zsl200911
    2015-07-14 22:18:27

    Element title = new Element("title");
       CDATA cdata = new CDATA("上海移动互联网产业促进中心正式揭牌 ");
       title.setText(cdata.toString());
       channel.addContent(title);

  • 风中过客
    2015-06-11 23:21:23

    好吧,隔壁有了


    Element title = new Element("title");

    CDATA cdata = new CDATA("上海移动互联网产业促进中心正式揭牌");

    title.setContent(cdata);

     JessicaJiang