Last active
September 30, 2015 05:07
-
-
Save cowlike/1726151 to your computer and use it in GitHub Desktop.
This file contains 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
from: www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx | |
XDocument doc = new XDocument( | |
new XDeclaration("1.0", "utf-8", "yes"), | |
new XComment("Sample RSS Feed"), | |
new XElement("rss", | |
new XAttribute("version", "2.0"), | |
new XElement ("channel", | |
new XElement("title", "RSS Channel Title"), | |
new XElement("description", "RSS Channel Description."), | |
new XElement("link", "http://aspiring-technology.com"), | |
new XElement("item", | |
new XElement("title", "First article title"), | |
new XElement("description", "First Article Description"), | |
new XElement("pubDate", DateTime.Now.ToUniversalTime()), | |
new XElement("guid", Guid.NewGuid())), | |
new XElement("item", | |
new XElement("title", "Second article title"), | |
new XElement("description", "Second Article Description"), | |
new XElement("pubDate", DateTime.Now.ToUniversalTime()), | |
new XElement("guid", Guid.NewGuid())) | |
) | |
) | |
); | |
XElement xml = new XElement("contacts", | |
from c in db.Contacts | |
orderby c.ContactId | |
select new XElement("contact", | |
new XAttribute("contactId", c.ContactId), | |
new XElement("firstName", c.FirstName), | |
new XElement("lastName", c.LastName)) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment