hd112
hd112

Reputation: 279

Can an tinyxml someone explain which characters need to be escaped?

I am using tinyxml to save input from a text ctrl. The user can copy whatever they like into the text box and it gets written to an xml file. I'm finding that the new lines don't get saved and neither do & characters. The weird part is that tinyxml just discards them completely without any warning. If I put a & into the textbox and save, the tag will look like:

<textboxtext></textboxtext>

newlines completely disappear as well. No characters whatsoever are stored. What's going on? Even if I need to escape them with &amp or something, why does it just discard everything? Also, I can't find anything on google regarding this topic. Any help?

EDIT: I found this topic which suggest the discarding of these characters may be a bug.
TinyXML and preserving HTML Entities

Upvotes: 2

Views: 1565

Answers (1)

Matthieu M.
Matthieu M.

Reputation: 300429

It is, apparently, a bug in TinyXml.

The simple workaround is to escape anything that it might not like:

  • &, ", ', < and > got their regular xml entities encoding
  • strange characters (read non-alphanumerical / regular punctuation) are best translated to their unicode codepoint: &#....;

Remember that TinyXml is before all a lightweight xml library, not a full-fledged beast.

Upvotes: 1

Related Questions