为什么 XML 适合数据文件? [英] Why is XML good for data files?

查看:26
本文介绍了为什么 XML 适合数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我工作的研究小组一直在研究一些模拟代码.

Recently the research group I have been working in have been working on some simulation codes.

对于代码,我们有包含代码的主要 C++ 文件,包含模拟输入参数的文本文件.每个时间步的模拟数据以柱状数据的形式吐出,其中每一列代表某个物理量位置、压力等,每一行代表一个网格点.

For the codes we have the main C++ files containing the code, a text file containing input parameters for the simulation. The data of the simulation at every time step is spitted out in the form of columnar data where each column representing some physical quantity position, pressure, etc. and each row represents a grid point.

我的老板现在让我把输入参数文件和输出数据文件的数据格式从现在的 key-value ,key-value 性质转换为 XML 格式.他似乎是他的解释很差,因为他的英语很烂.他已经有两次大吼大叫 XML 的优越性,而我一个字都没听懂.

My boss has now asked me to switch the data format of the input-parameter-file and output data files to the XML format from its present key-value , key-value nature. He seems to be very poor at his explanations since his English pretty much sucks. Its been two times now that he ranted about the superiority about XML without me understanding a word.

现在,让我说我只是对科学计算感兴趣的普通 C/C++/Python 程序员,我没有计算机工程学科的背景,例如数据库或 XML 似乎最常用的 Web 开发.

Now, Let me say I am just your average C / C++ / Python programmer interested in scientific computing, and I have no back-ground in Computer Engineering subjects like databases or web development that XML seems to be used most in.

谁能给我一个简短的解释,或者向我指出一些资源用简单但不平凡的例子对概念进行温和的解释,没有所有 XML 教程似乎充斥的所有瑜伽、诵经、香火和丑陋的技术词汇(这些词汇一直需要我做无休止的谷歌搜索).

Can anyone give me a short explanation of this or else point me to some resources which offer a gentle explanation of the concepts with simple yet non-trivial examples without all the yoga, chanting, incense burning , and ugly technical vocabulary (which keep requiring me to do endless googling) that all the XML tutorials seem to be filled with.

如果有人可以给出一些明确的现实例子,说明 XML 数据格式在某些领域中的使用地点和方式应用数学代码真的很有帮助.

If someone can give some explicit real-life examples of where and how the XML data format is used in some applied mathematics codes that will really be helpful.

推荐答案

简而言之,XML 提供了与各种软件互操作的能力,因为可以使用 XML 语言交换 XML 数据.

Briefly, XML offer the ability to be interoperable with a wide variety of software, since XML data can be exchanged by using the XML language.

例如,相同的数据可以包含在 HTML 页面中以供显示,或者可以由其他知道数据模式(XML 模式)的应用程序按原样"读取,或者可以使用任何文本格式转换为任何文本格式XSLT.(即 XML 到 CSV).

For example, the same data can be included in an HTML page for display, or can be read "as is" by other application aware of the data schema (XML schema), or can be transformed in any text format by using XSLT. (i.e. XML to CSV).

总而言之,XML 可以比任何其他数据格式更容易移植.

In conclusion, XML can be ported more easily than any other data format.

当然,这不是使用 XML 数据的唯一好处:XML 可以根据其架构验证文档(为了正确性),可以使用声明语言 (XPath) 查询数据.

Of course this is not the only benefit of using XML for data: XML can validate a document against its schema (for correctness), the data can be queried with a declaration language (XPath).

对于需要/产生大量数据的应用程序来说,XML 的一个缺点是 XML 是冗长的(写入任何二进制数据格式):想想如何保存图像,例如,在 XML 中......那会很麻烦... 当然,您可以在 XML 文档中包含二进制数据(通过使用 base64 编码),但在这种情况下(大多数数据以 base64 存储),使用 XML 没有意义.

A disadvatage of XML, for application that requires/produce lots of data is that XML is verbose (w.r.t. any binary data format): think how to save an image, for instance, in XML... That would be cumbersome... Of course you can include binary data in the XML document (by using base64 encoding), but in this cases (where most of the data is stored in base64) it make no sense to use XML.

这篇关于为什么 XML 适合数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆