缩进 XML 文件的重要性 [英] Importance of indenting XML file

查看:61
本文介绍了缩进 XML 文件的重要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否需要缩进 XML 文件中的 XML 标签才能成功解析文件?

Is it necessary to indent the XML tags in a XML file for successful parsing of the file?

推荐答案

否,XML 规范 像这样定义空格:

No, the XML spec define whitespace like this:

在编辑 XML 文档时,使用空格"通常很方便(空格、制表符和空行)将标记分开以获得更大的可读性.这种空白通常不用于包含在文档的交付版本中.另一方面,交付时应保留的重要"空白版本很常见,例如在诗歌和源代码中.

In editing XML documents, it is often convenient to use "white space" (spaces, tabs, and blank lines) to set apart the markup for greater readability. Such white space is typically not intended for inclusion in the delivered version of the document. On the other hand, "significant" white space that should be preserved in the delivered version is common, for example in poetry and source code.

所以在解析文档方面,没有.您可以根据需要或需要尽可能多地或尽可能少地使用它,它会解析正确.然而,这可能会也可能不会改变 XML 文档的含义.

So in terms of parsing the document, no. You can use as much or as little as you want or need and it will parse correctly. This may or may not change the meaning of the XML document, however.

解析从不需要缩进 XML 标签.然而,XML 的重点是人类和机器可读,因此缩进通常值得拥有,因为它使人类读者更容易使用和一目了然地理解结构.

Indenting XML tags is never required for parsing. However, the point of XML is to be human as well as machine readable, so indentation is generally worth having, as it makes it far easier for human readers to work with and take in the structure at a glance.

这篇关于缩进 XML 文件的重要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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