I'd suggest storing templates
XElement
in a variable before adding it into your document:
XElement templates = new XElement("templates");
Response.Add(templates );
And then use it to add templates:
var t = from e1 in wlnResponse.Elements()
where e1.Name.ToString() == "templates"
select e1;
templates.Add(t.ToArray());