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?
No, mixing elements and text is completely normal in XML.
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.
In XML Schema (XSD), mixed="true" designates mixed text in a content model.
I think it's best to reserve mixed content for one purpose only: to annotate (or "mark-up") sections of natural language text. So a good test to apply is, does the text still make sense if the markup is removed?
In your example, my only criticism would be that if you remove the markup, what's left isn't grammatical: it's missing a full-stop after the first sentence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With