English 中文(简体)
XML为什么对数据文件有用? [关闭]
原标题:Why is XML good for data files? [closed]
  • 时间:2012-05-27 20:46:20
  •  标签:
  • xml
Closed. This question is opinion-based. It is not currently accepting answers.

想要改进这个问题吗? 更新问题,以便用

Closed 10 years ago.

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

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.

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似乎最常用的数据库或网络开发。

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.

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语言进行交换。

例如,同一数据可以包含在用于显示的 HTML 页面中,也可以通过了解数据模式(XML schema)的其他应用程序读出“和现在一样”,也可以通过使用 XSLT(即XML 到 CSV)转换成任何文本格式。

总之,XML比任何其他数据格式更容易移植。

当然,这并非数据使用XML的唯一好处:XML可以对照其计划(正确性)验证文件,数据可以用声明语言(XPath)查询。

XML的脱空, 用于需要/ 生成大量数据的应用程序是 XML 是verbose (w.r.t. 任何二进制数据格式): 思考如何保存图像, 例如 XML... 这将会很麻烦... 当然, 您可以在 XML 文档中包含二进制数据( 使用 base64 编码 ), 但在这种情况下( 大部分数据存储在 base64 中), 使用 XML 毫无意义 。

另外,XML是一种非常灵活的格式。 保存数据很容易,数据的结构各不相同,同时由于DTD、XSD或放松NG而保持了明确、正式的定义。

例如,与表格相比,它可以消除可能的空单元格,这些空单元格(对于足够大的数据集来说)甚至可以弥补其动词。

表格数据 :

 ID  | attribute1 | attribute2 | attribute3 | attribute4 | attribute5 | etc.
 1   |     1      |     3      |      8     |    null    |    7       |  ...
 2   |     4      |    null    |     null   |    null    |    13      |  ...
 3   |     4      |    null    |      1     |     12     |   null     |  ...

XML: (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑) (笑)

<rows>
  <row id="1">
    <attribute1>1</attribute1>
    <attribute2>3</attribute2>
    <attribute3>8</attribute3>
    <attribute5>7</attribute5>
  </row>
  <row id="2">
    <attribute1>4</attribute1>
    <attribute5>13</attribute5>
  </row>
  <row id="3">
    <attribute1>4</attribute1>
    <attribute3>1</attribute3>
    <attribute4>12</attribute4>
  </row>
</rows>

Not to mention the fact that each row could have a complex, individual structure. You could describe a very long polynomial expression or literally any other function this way.

我相信许多应用应用高级数学的应用程序都使用XML。 我知道数学允许 XML 导出。 Matlab 和 R 也允许 。

使用XML的另一个好处是它既容易被机器分析,又很容易被人类读懂。你不需要解码它(如二进制),你可以清楚地看到数据的结构(与 Csv 或许多其他格式不同 ) 。

其受欢迎程度和大量工具也不容忽视。

使用 XML 将您数据的长期价值最大化, 因为它的表达形式与您打算如何使用该数据的方式无关, 也与任何特定软件环境的权宜性无关。 基本上如此。 通常, 当您将软件和数据作为长期资产处理时, 您可能不得不为实现近期短期目标做一些“ 超生工程 ”, 但是您( 或您的老板)正在进行一场有计划的赌博, 投资将在长期内得到回报 。

想想一个任何软件或硬件都使用自己格式的世界。 Microsoft Word.doc 文件有一定的结构( 定义字体、 尺寸、 校正、 ecc), 不同于.pdf 。

我可以无穷无尽地继续告诉你,有些格式与其他格式不同,但结果(文本文件、视频、图像)与其他格式一样。 互联网上的人要求“我如何在操作系统里打开该文件? ”或者“我如何在应用程序中打开该文件”, Ecc 。

Software company companys never really wanted to application the soft companits to companits to remote the show commonts, 相反,它们通过创建新标准(通常与其它标准不兼容),将这种痛苦(a-a-a

任何浏览器开发者都必须做一个必须更好、 更轻、 最冷却的应用程序, 以便做什么? 只要读取并形成一种现有格式: HTML 页面 。

Told that, you may guess why XML is a good format to use ;) Ideally, everything should be in .txt only format. Now tell me, could you write an XML file without an XML editor (just by using the notepad)? Can you do the same with a pdf? Or with a doc?

据我所知,没有“明确的真实生活中的例子,说明XML数据格式在某些应用数学代码中在何处和如何使用”,但不幸的是,计算机科学不仅涉及“应用数学”,而且涉及一些我们所关心的细小的废话,如格式。

XML 不适宜于数据结构或关键值对的 XML。 使用 JSON 或 YAML 进行数据结构或关键值对的 XML 。 另一方面, XML 适合于文档标记 。





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml