java - 如何在 xml 文件中将“实体”更改为“实体”
问题描述
在数据库中,我有一个包含"it's"
在字符串中的消息模板,所以当我采用该消息模板并制作 xml 格式时,我得到it's
了 xml 标记。
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""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""s
这被替换为it's
解决方案
正如 yash 建议的那样,您可以在编辑之前在 xml 变量上使用 org.apache.commons.lang.StringEscapeUtils:
StringEscapeUtils.unescapeXml(xml);
推荐阅读
- php - PHP - 如何从动态 JSON 响应中获取键值
- java - Spring Data Mongodb是否应该嵌套文档
- python - 你能帮我解决这个问题吗?我只是个初学者
- python - Python可以从数据透视表字段中选择一个值并且该数据透视表来自现有连接
- html - 当容器调整大小时,如何使圆圈保持形状?
- javascript - javascript点击事件后不需要的1秒延迟
- ruby-on-rails - Rails 迁移抱怨“add_attachment”
- javascript - 用 vanillaJS 处理插入符号(文本插入点)
- c# - 管理 datagridview 单元格值时应用程序冻结
- java - RxJava:通过在 Observable.create() 中嵌套事件源将回调转换为反应流,而不是存储 ObservableEmmiter