Nested exception: The entity name must immediately follow the '&' in the entity refere

编程知识 更新时间:2023-05-02 18:58:51

先来说说异常

当我使用dom4j来将String类型转换成Document 时

String 里面包含了“&”符号,结果异常就这样出来了

Nested exception: The entity name must immediately follow the '&' in the entity reference

此时,该如何解决呢?

解法:

通过将String 内容replace掉、即string.replace("&", "XXX");

但这个XXX该填成什么值 dom4j才会把他当成原始的“&”保存在xml中呢?

大家细瞧dom4j的文档就可知道String 和xml转换时 “&” 是被当成“&”值来传递的


所以这里 只要 通过string.replace("&", "&")  便可以成功的把“&”保存到xml中了!


更多推荐

Nested exception: The entity name must immediately follow the '&'

本文发布于:2023-04-28 04:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/a8fbfc7e56fb692df43bd4eddb20dd28.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:entity   exception   Nested   immediately   reference

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 107559文章数
  • 27222阅读数
  • 0评论数