In VB.NET I can easily embed strings into XML literals using <xml><%= "my string" %></xml>
.
How can I embed an XElement
instance?
I know I can use methods on the XElement, XNode, etc classes, but I'd like to do it in the XML literals if possible.
It turns I can simply do the following:
Function GetSomeMoreXml() As XElement
Return <moreXml/>
End Function
Sub Main()
Dim myXml = <myXml>
<%= GetSomeMoreXml() %>
</myXml>
End Sub
Which is pretty neat. It allows me to break up my XML literals into more manageable chunks.