Created
January 31, 2014 14:57
-
-
Save JAChapmanII/8733593 to your computer and use it in GitHub Desktop.
Short untested example of what some XDocument/LINQ usage in C# would convert to in VB.Net with XML literals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument | |
// Customers is a List<Customer> | |
XElement customersElement = new XElement("customers", | |
customers.Select(c => new XElement("customer", | |
new XAttribute("name", c.Name), | |
new XAttribute("lastSeen", c.LastOrder) | |
new XElement("address", | |
new XAttribute("town", c.Town), | |
new XAttribute("firstline", c.Address1), | |
// etc | |
)); | |
' Customers is a List(Of Customer) | |
Dim customersElement = | |
<customers> | |
<%= From c In Customers Select | |
<customer name=<%= c.Name %> lastSeen=<%= c.LastOrder %>> | |
<address town=<%= c.Town %> firstline=<%= c.Address1 %> ...etc... /> | |
</customer> | |
%> | |
</customers> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment