关于转义, 不会用。。。

来源:5-3 JDOM 设置 XML 格式

风中过客

2015-06-11 23:11

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


写回答 关注

3回答

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

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

    soft_x...

    哈哈,你做出来没

    2017-03-10 11:30:48

    共 1 条回复 >

  • 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


    袁又袁

    没办法用实现策略接口的方式对字符不进行转义来实现么?

    2015-07-07 19:20:01

    共 1 条回复 >

Java眼中的XML 文件写入

举例说明JAVA程序如何生成XML文档,多种生成方式任你选择

55798 学习 · 132 问题

查看课程

相似问题