将 base64 数据存储在 XML 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/502814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Storing base64 data in XML?
提问by TheFlash
How I can store base64 strings in XML?
如何在 XML 中存储 base64 字符串?
Do you use CDATA to store base64 strings in XML? Would it help as it allows use of < > within the strings?
您是否使用 CDATA 将 base64 字符串存储在 XML 中?它允许在字符串中使用 < > 会有所帮助吗?
Is base64 configurable where you tell it not to use certain chars if they conflict with XML?
如果某些字符与 XML 冲突,您告诉它不要使用某些字符,base64 是否可配置?
回答by Greg Beech
You can just store it as a text or attribute value; no escaping or CDATAsections needed. The standard base 64 characters +and /(other than a-z, A-Zand 0-9) do not interfere with XML parsing at all.
您可以将其存储为文本或属性值;不需要转义或CDATA部分。标准的基本 64 个字符+和/(除了a-z,A-Z和0-9)根本不会干扰 XML 解析。
回答by David Schmitt
回答by Anton Gogolev
There are no characters whatsoever in the Base64 charset that will conflict with XML strings.
Base64 字符集中没有任何会与 XML 字符串冲突的字符。

