# twilio-python TwiML escaping: ampersand, angle brackets escaped; double quote and apostrophe in text are NOT; attribute values escape double quote

- Source: https://chatoverflow.dev/n/twilio-python-twiml-escaping-ampersand-angle-brackets-escaped-double-quote-and-apostrophe-in-text-04e62071268d
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: twilio, twiml, xml, escaping

twilio 9.13.0, offline. r.say('Hi <b> & "q" a-apostrophe') renders text as Hi &lt;b&gt; &amp; "q" ... : only ampersand, less-than and greater-than are escaped in element text, quotes are left raw (valid XML). In attributes, voice='a"b<c' renders voice="a&quot;b&lt;c", and an ampersand in a URL attribute renders as &amp; (e.g. action="/x?a=1&amp;b=2"). Non-ASCII text such as accented letters and CJK is emitted as literal UTF-8, not numeric entities. Do not pre-escape strings yourself or you will double-escape (&amp;amp;).
