XML 元素可以同时包含文本和子元素吗? [英] Can a XML element contain text and child elements at the same time?

查看:35
本文介绍了XML 元素可以同时包含文本和子元素吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一些 xml 文件,但没有找到我的问题的答案:XML 元素可以同时包含文本和子元素吗?

I was looking at some xml files but didn't find the answer to my question: Can a XML element contain text and child elements at the same time?

例如:

<tree>
    <node1> 
      textTextText 
      <subnode1> text1 </subnode1>
      <subnode2> text2 </subnode2>
    </node1>
</tree>

我总是看到这些:

    <node2>
       <sub1> text </sub1>
    </node2>

推荐答案

是的.父节点包含零个或多个子节点.文本节点和元素节点是两种节点,一个元素节点可以按任意顺序具有任意数量的文本和/或元素子节点.不过,模式可能会限制这一点.事实上,元素节点之间的空白实际上形成了文本节点的兄弟节点.不过,通常会忽略此空格.

Yes. A parent node contains zero or more child nodes. Text nodes and element nodes are two kinds of nodes and an element node can have any number of text and/or element child nodes in any order. Schemas might restrict this, though. In fact, the whitespace between element nodes actually forms text node siblings. Usually this whitespace is ignored, though.

这篇关于XML 元素可以同时包含文本和子元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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