예제 #1
0
 public NewsEntry(AtomData title, AtomData content, DateTime updated, string authorName)
 {
     Title      = title;
     Content    = content;
     Updated    = updated;
     AuthorName = authorName;
 }
예제 #2
0
        private static void LoadAtomEntry(List <NewsEntry> news, XmlNamespaceManager nsMgr, XmlElement entry)
        {
            AtomData title       = GetAtomData((XmlElement)entry.SelectSingleNode("atom:title", nsMgr), nsMgr);
            AtomData content     = GetAtomData((XmlElement)entry.SelectSingleNode("atom:content", nsMgr), nsMgr);
            string   updatedText = entry.SelectSingleNode("atom:updated", nsMgr).InnerText;
            DateTime updated     = DateTime.Parse(updatedText);
            string   authorName  = entry.SelectSingleNode("atom:author/atom:name", nsMgr).InnerText;

            news.Add(new NewsEntry(title, content, updated, authorName));
        }
예제 #3
0
        private static AtomData GetAtomData(XmlElement elm, XmlNamespaceManager nsMgr)
        {
            string       dataTypeName = elm.GetAttribute("type");
            AtomDataType dataType;

            if (dataTypeName == "text")
            {
                dataType = AtomDataType.Text;
            }
            else if (dataTypeName == "html")
            {
                dataType = AtomDataType.HTML;
            }
            else
            {
                throw new InvalidDataException("Atom data type must be [text] or [html]");
            }
            string   data     = elm.InnerText;
            AtomData atomData = new AtomData(dataType, data);

            return(atomData);
        }