简体   繁体   中英

RSS pubDate always “01-Jan-01 12:00:00 AM”

I try to get pubDate value from RSS feed 2.0 but it always = "01-Jan-01 12:00:00 AM" here is the rss feed

 <item>
<title>title</title> 
<description>desc</description>
<link>http://somelink.com</link>
<pubDate>Thu, 31 Jul 2014 11:13:58</pubDate>
<guid></guid>
<enclosure"/>
</item>

and my class is

public class Item 
    {
        [XmlElement("title")]
        public string Title { get; set; }

        [XmlElement("description")]
        public string Description { get ; set; }

        [XmlElement("pubdate")]
        public DateTime Pubdate { get; set; }

        [XmlElement("link")]
        public string Link { get; set; }
    }

All items is working fine except pubDate always "01-Jan-01 12:00:00 AM". Any help?

You are not telling the XMLParser about the format of the property. Try

[XmlElement("pubdate", DataType = "date")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM