【问题标题】:how to change ' entity to ' in xml file如何在 xml 文件中将“实体”更改为“实体”
【发布时间】:2019-03-25 08:35:57
【问题描述】:

在数据库中,我有一个在字符串中包含 "it's" 的消息模板,所以当我采用该消息模板并制作 xml 格式时,我在 xml 标记中得到 it's

sms.setMessage(createSMS.messageFormatter(sms).getMessage());

tagList = new TagList[4]; 
req.setTaglist(tagList);
tagList[0] = new TagList();
tagList[0].setTagName("OA");
tagList[0].setTagValue(dto.getDaInk());

tagList[1] = new TagList();
tagList[1].setTagName("DA");
sms.setMsisdnTosent(Utilities.appendCountryCode(sms.getMsisdnTosent()));
tagList[1].setTagValue(sms.getMsisdnTosent());    

tagList[2] = new TagList();
tagList[2].setTagName("MESSAGE");
tagList[2].setTagValue(sms.getMessage());

tagList[3] = new TagList();
tagList[3].setTagName(Tags.TONE_ID);
tagList[3].setTagValue(sms.getSongId());

我是这样的,

<tagData>
      <name>MESSAGE</name>
      <value>Dear customer it&quot;&quot;s a confirmation messege sent to activate  Tune ALLAHUMMA EGHFER LE ABAENA WA OMMAHATENA you just heard Latest,reply with *  to copy the Tune, of artist AL SHEIKH MAHER BIN HAMAD AL MUAIQLY and toneId is 176577,cndtn aply.</value>
</tagData>

但我想,it&amp;quot;&amp;quot;s 替换为 it's

【问题讨论】:

  • 您能否展示一下您用于从 taglist 数组中编辑 xml 的代码?
  • 你读过org.apache.commons.lang.StringEscapeUtils吗?
  • 一个单引号'怎么变成了两个双引号""???

标签: java xml


【解决方案1】:

根据 yash 的建议,您可以在编辑之前对 xml 变量使用 org.apache.commons.lang.StringEscapeUtils:

StringEscapeUtils.unescapeXml(xml);

【讨论】:

    猜你喜欢
    • 2019-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-14
    • 2013-01-08
    • 1970-01-01
    • 2011-07-24
    相关资源
    最近更新 更多