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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With