简体   繁体   English

如何将音频,图像和二进制文件存储为XML?

[英]How to store audio, images, and binary files as XML?

I'm reading a book on .NET, and it says "XML can be used to store any type of data including documents (the latest version of Microsoft Office stores documents using XML), pictures, music, binary files, and database information." 我正在阅读.NET上的书,书中说:“ XML可用于存储任何类型的数据,包括文档(Microsoft Office的最新版本使用XML存储文档),图片,音乐,二进制文件和数据库信息。 “

Huh? 咦? How can those types of data be stored as XML? 这些类型的数据如何存储为XML?

Office documents are actually ZIP files containing compressed files, mostly in XML. Office文档实际上是包含压缩文件的ZIP文件,大多数为XML。 When you have an embedded image, it just stores it in the media subdirectory as a binary file. 当您拥有嵌入式图像时,它只是将其作为二进制文件存储在media子目录中。 The XML references it by name, but does not contain a base 64 representation of the contents. XML通过名称引用它,但不包含内容的base 64表示形式。

In most of the time you just use base64 encoding and then just save this. 在大多数情况下,您只使用base64编码,然后保存即可。

In some cases you can of course use a native xml format that does not require encoding. 在某些情况下,您当然可以使用不需要编码的本机xml格式。 Such as SVG for vector graphics etc. 例如用于矢量图形的SVG等。

您可以将它们转换为base64并将其存储在xml中: 以XML存储base64数据吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM