예제 #1
0
파일: RssFeed.cs 프로젝트: youye00/higlabo
        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);
            }
        }