在XML中将元素节点作为文本节点的兄弟姐妹是错误的吗? [英] Is it wrong in XML to have element nodes as siblings of text nodes?

查看:77
本文介绍了在XML中将元素节点作为文本节点的兄弟姐妹是错误的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是允许"使用XML还是仅仅是对XML的错误使用?我对此没有限制,但是感觉有点奇怪.

Is the following "allowed" or simply bad use of XML? I cannot find restrictions on this, but it feels a bit weird.

<example>
    You can choose from
    <option>this</option>
    <option>that</option>
    <option>something else</option>
    Choose wisely.
</example>

如果错了,还有什么更好的选择?

If it is wrong, what is a nice alternative?

推荐答案

不,在XML中混合元素和文本是完全正常的.

No, mixing elements and text is completely normal in XML.

您可能更熟悉XML的面向数据的用法,但是XML实际上是从表示文档的基础演变而来的,在该文档中标记其他文本为标准.它的前身SGML就是这样,而HTML至今仍是这样.

You may be more familiar with data-oriented uses of XML, but XML actually evolved from a basis in representing documents, where marking up text within other text is the norm. Its predecessor, SGML, was like this, and HTML is still like this today.

在XML模式(XSD)中,mixed="true"在内容模型中指定混合文本.

In XML Schema (XSD), mixed="true" designates mixed text in a content model.

这篇关于在XML中将元素节点作为文本节点的兄弟姐妹是错误的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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