Actually, come to think of it, I think all you really have to do here is use double-quotes instead of single ones, then manually escape the double-quotes you want to output.
Code:
$ TitleText="This is a title" LabelText="This is a label"
$ export MAIN_DIALOG="
<window title=\"$TitleText\">
<text>
<label>$LabelText</label>
</text>
</window>
"
$ echo "$MAIN_DIALOG"
<window title="This is a title">
<text>
<label>This is a label</label>
</text>
</window>
FYI, double-quotes (") escape all characters except for $ \ and ` (dollar sign, backslash, and backquote). This way you can still use variables, command substitution, and escape sequences in your text string. Note that the single-quote is escaped while inside them, too.
Single-quotes ('), OTOH, make literal
everything except another single-quote. You can't use any commands or variables, or escape anything, while inside them.
The
ABSG section on quoting will give you more details.