Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 xStream 对对象进行序列化和反序列化。但是,当任何标签值都存在“&”时,xStream 将失败并抛出异常。
例如,这失败了..
<tag>value & value</tag> Exception :- "An entity name must immediately follow..." <tag>value value</tag> this passes
有没有办法告诉 xStream 忽略某些字符
谢谢!普拉提克
这是格式不正确的 XML,任何 XML 解析器(不仅仅是 XStream)都应该失败。&应该在编码(写入)文档时翻译成&。
&
&
我会确定正在编写该文档的内容并修复字符编码,然后任何读取过程都应该可以正常工作。