Пример #1
0
        public static RssFeed Parse(String xml)
        {
            XDocument doc = null;

            try
            {
                doc = XDocument.Parse(xml);
            }
            catch
            {
                throw new RssParseException(xml);
            }
            var root    = doc.Root;
            var version = ParseVersion(root);

            if (version.HasValue == false)
            {
                throw new RssParseException(xml);
            }

            if (version.Value == RssVersion.Atom)
            {
                var parser = new AtomParser();
                return(parser.Parse(xml));
            }
            else
            {
                var parser = RssParser.Create(version.Value);
                return(parser.Parse(xml));
            }
        }
Пример #2
0
        public static RssFeed Parse(String xml)
        {
            XDocument doc = null;
            try
            {
                doc = XDocument.Parse(xml);
            }
            catch
            {
                throw new RssParseException(xml);
            }
            var root = doc.Root;
            var version = ParseVersion(root);
            if (version.HasValue == false) { throw new RssParseException(xml); }

            if (version.Value == RssVersion.Atom)
            {
                var parser = new AtomParser();
                return parser.Parse(xml);
            }
            else
            {
                var parser = RssParser.Create(version.Value);
                return parser.Parse(xml);
            }
        }