/// <summary>
        /// Provides example code for the Load(XmlReader) method
        /// </summary>
        public static void LoadXmlReaderExample()
        {
            #region Load(XmlReader reader)
            OpmlDocument document = new OpmlDocument();

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Open, FileAccess.Read))
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments   = true;
                settings.IgnoreWhitespace = true;

                using (XmlReader reader = XmlReader.Create(stream, settings))
                {
                    document.Load(reader);

                    foreach (OpmlOutline outline in document.Outlines)
                    {
                        if (outline.IsSubscriptionListOutline)
                        {
                            //  Process outline information
                        }
                    }
                }
            }
            #endregion
        }
Beispiel #2
0
 public void ReadSubscriptions(string opmlPath)
 {
     using (var stream = new StreamReader(opmlPath))
     {
         _opmlDocument = new OpmlDocument();
         _opmlDocument.Load(stream.BaseStream);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public void Load(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(Resources.RssToolkit.Culture, Resources.RssToolkit.ArgmentException, "xml"));
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(xml);

            Load(opmlDoc);
        }
Beispiel #4
0
        /// <summary>
        /// Loads from URL.
        /// </summary>
        /// <param name="opmlUrl">The opml URL.</param>
        public void Load(System.Uri opmlUrl)
        {
            if (opmlUrl == null)
            {
                throw new ArgumentNullException("opmlUrl");
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(opmlUrl);

            Load(opmlDoc);
        }
Beispiel #5
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public void Load(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The argument '{0}' is Null or Empty", "xml"));
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(xml);

            Load(opmlDoc);
        }
Beispiel #6
0
        /// <summary>
        /// Provides example code for the Load(Uri, ICredentials, IWebProxy) method
        /// </summary>
        public static void LoadUriExample()
        {
            OpmlDocument document = new OpmlDocument();
            Uri          source   = new Uri("http://blog.oppositionallydefiant.com/opml.axd");

            document.Load(source, CredentialCache.DefaultNetworkCredentials, null);

            foreach (OpmlOutline outline in document.Outlines)
            {
                if (outline.IsSubscriptionListOutline)
                {
                    //  Process outline information
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Provides example code for the Load(IXPathNavigable) method
        /// </summary>
        public static void LoadIXPathNavigableExample()
        {
            XPathDocument source = new XPathDocument("http://blog.oppositionallydefiant.com/opml.axd");

            OpmlDocument document = new OpmlDocument();

            document.Load(source);

            foreach (OpmlOutline outline in document.Outlines)
            {
                if (outline.IsSubscriptionListOutline)
                {
                    //  Process outline information
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Provides example code for the Load(Stream) method
        /// </summary>
        public static void LoadStreamExample()
        {
            OpmlDocument document = new OpmlDocument();

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Open, FileAccess.Read))
            {
                document.Load(stream);

                foreach (OpmlOutline outline in document.Outlines)
                {
                    if (outline.IsSubscriptionListOutline)
                    {
                        //  Process outline information
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Instantiates a <see cref="ISyndicationResource"/> that conforms to the specified <see cref="SyndicationContentFormat"/> using the supplied <see cref="Stream"/>.
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> used to load the syndication resource.</param>
        /// <param name="format">A <see cref="SyndicationContentFormat"/> enumeration value that indicates the type syndication resource the <paramref name="stream"/> represents.</param>
        /// <returns>
        ///     An <see cref="ISyndicationResource"/> object that conforms to the specified <paramref name="format"/>, initialized using the supplied <paramref name="stream"/>.
        ///     If the <paramref name="format"/> is not supported by the provider, returns a <b>null</b> reference.
        /// </returns>
        /// <exception cref="ArgumentNullException">The <paramref name="stream"/> is a null reference (Nothing in Visual Basic).</exception>
        private static ISyndicationResource BuildResource(SyndicationContentFormat format, Stream stream)
        {
            Guard.ArgumentNotNull(stream, "stream");

            if (format == SyndicationContentFormat.Apml)
            {
                ApmlDocument document = new ApmlDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Atom)
            {
                XPathDocument  document  = new XPathDocument(stream);
                XPathNavigator navigator = document.CreateNavigator();
                navigator.MoveToRoot();
                navigator.MoveToChild(XPathNodeType.Element);

                if (String.Compare(navigator.LocalName, "entry", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomEntry entry = new AtomEntry();
                    entry.Load(navigator);
                    return(entry);
                }
                else if (String.Compare(navigator.LocalName, "feed", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomFeed feed = new AtomFeed();
                    feed.Load(navigator);
                    return(feed);
                }
                else
                {
                    return(null);
                }
            }
            else if (format == SyndicationContentFormat.BlogML)
            {
                BlogMLDocument document = new BlogMLDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Opml)
            {
                OpmlDocument document = new OpmlDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Rsd)
            {
                RsdDocument document = new RsdDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Rss)
            {
                RssFeed feed = new RssFeed();
                feed.Load(stream);
                return(feed);
            }
            else
            {
                return(null);
            }
        }
Beispiel #10
0
 public static OpmlDocument GetOpmlDocumentFromXml()
 {
     return(OpmlDocument.Load(OpmlXml));
 }