I know you said C# but have you tried VB.NET for XML Literals. Amazing stuff.
Public Class Program
Public Shared Sub Main()
Dim myKeyBoardStyle = "dvorak"
Dim myXML As XElement = <ROOT>
qwerty
<altKeyboard><%= myKeyBoardStyle.ToUpper() %></altKeyboard>
<SampleElement>adsf</SampleElement>
<SampleElement2>The text of the sample element2</SampleElement2>
</ROOT>
Console.WriteLine(myXML.ToString())
myXML.Save(".\fileFromXElement.xml")
End Sub
End Class
Notice the neat element which injects the result of code in into the output:
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
qwerty
<altKeyboard>DVORAK</altKeyboard><SampleElement>adsf</SampleElement><SampleElement2>The text of the sample element2</SampleElement2></ROOT>
snip [removed opinions]