JavaDeveloper
JavaDeveloper

Reputation: 5660

Does only the child element contain text/data in xml

For example, assume that we have an element "car" which contains child elements like color, wheels etc each with its own text eg: color: red and wheel four. But can "car" itself contain text like BMW ?

Upvotes: 0

Views: 34

Answers (2)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56202

Yes, it is allowed and XML will be well-formed. Anyway, you should avoid doing so if possible.

Upvotes: 1

Pawel
Pawel

Reputation: 31620

Yes. It's called mixed content e.g.:

<root>
  <element>abc<child>xyz</child>def<child>nop</child>hij</element>
</root>

is valid xml.

Upvotes: 1

Related Questions