I have an xml feed from Gmail as such:
<feed version="0.3">
<title>Gmail - Inbox for bagee18@gmail.com</title>
<tagline>New messages in your Gmail Inbox</tagline>
<fullcount>9</fullcount>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html"/>
<modified>2012-07-19T02:43:55Z</modified>
<entry>
<title>$50 or $100 Nightly Resort Credit and Room Upgrade</title>
<summary>Add to Address Book | Update email address Marriott® FIND A HOTEL EXPLORE PLAN MARRIOTT REWARDS</summary>
<link rel="alternate" href="http://.google.com" type="text/html"/><modified>2012-07-19T01:23:00Z</modified>
<issued>2012-07-19T01:23:00Z</issued>
<id>tag:gmail.google.com,2004:1407882080256681207</id>
<author>
<name>Marriott</name>
<email>Marriott@marriott-email.com</email>
</author>
</entry>
<entry>
<title>Tim Anderson's ITWriting » Blog Archive Resort » Moving a database from on-premise SQL Server to SQL Azure: some hassle</title>
<summary>Tim Anderson's ITWriting Tech writing blog Home Articles Reviews Gadget Writing Forthcoming</summary>
<link rel="alternate" href="http://google.comen" type="text/html"/><modified>2012-07-19T00:55:25Z</modified>
<issued>2012-07-19T00:55:25Z</issued>
<id>tag:gmail.google.com,2004:1407880344364808586</id>
<author>
<name>me</name>
<email>bagee18@gmail.com</email>
</author>
</entry>
I created a LinqPad query as such:
XDocument xmlDoc = XDocument.Load(@"C:\Users\Brad Agee\Documents\feeds.xml");
var q = from c in xmlDoc.Descendants("entry")
where c.Element("title").Value.ToLower().Contains("resort")
select new {
name = c.Element("title").Value,
url = ??,
email ??
};
q.Dump();
How can I extract the value of href attribute of the link tag into the url property and the value of email attribute into the email property?
Well.
Href is an attribute of the element link.
So
email is an element of the element author
So
finally