sách gpt4 ăn đã đi

xml - Trình đọc XML có nên bỏ qua các khoảng trắng liên tiếp trong tệp XML không?

In lại 作者:数据小太阳 更新时间:2023-10-29 02:48:23 30 4
mua khóa gpt4 giày nike

在我的工作中,我们有自己的 XML 类来构建 DOM,但我不确定应该如何处理连续的空格?

Ví dụ


Xin chào thế giới

当它被读入 DOM 时,文本节点应该包含 Hello 和 World 之间的连续空白还是只将其减少到一个空格?

或者XML源应该这样写:

Hello     World

或者如果不是  比也许 ?

câu trả lời hay nhất

听说人们甚至不看 XML 规范就实现 XML 处理器,这有点令人不安。

từXML 1.0 specification, section 2.10 White Space Handling" (强调我的):

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.

An XML processor MUST always pass all characters in a document that are not markup through to the application. A validating XML processor MUST also inform the application which of these characters constitute white space appearing in element content.

A special attribute named xml:space may be attached to an element to signal an intention that in that element, white space should be preserved by applications. In valid documents, this attribute, like any other, MUST be declared if it is used. When declared, it MUST be given as an enumerated type whose values are one or both of "default" and "preserve". For example: ...

关于xml - XML 阅读器是否应该忽略 XML 文件中的连续空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/449532/

30 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress