Can a XML element contain text and child elements at the same time?

前端 未结 2 1954
梦毁少年i
梦毁少年i 2020-12-15 15:52

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?

For example:

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 16:28

    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.

提交回复
热议问题