Example #1
0
 private static void readRssImage(RssImage img, XmlReader reader)
 {
     if (equal(reader, "title"))
     {
         img.Title = reader.ReadString();
     }
     else if (equal(reader, "url"))
     {
         img.Url = reader.ReadString();
     }
     else if (equal(reader, "link"))
     {
         img.Link = reader.ReadString();
     }
     else if (equal(reader, "description"))
     {
         img.Description = reader.ReadString();
     }
     else if (equal(reader, "width"))
     {
         img.Width = cvt.ToInt(reader.ReadString());
     }
     else if (equal(reader, "height"))
     {
         img.Height = cvt.ToInt(reader.ReadString());
     }
 }
Example #2
0
 public static RssChannel Create( String rssUrl ) {
     RssChannel feed = new RssChannel();
     RssImage img = new RssImage();
     XmlTextReader reader = new XmlTextReader( rssUrl );
     Boolean isNewItem = false;
     Boolean isImage = false;
     RssItem rssItem = new RssItem();
     reader.MoveToContent();
     while (reader.Read()) {
         if (!reader.Name.Equals( "channel" ) && ((reader.NodeType != XmlNodeType.Whitespace) && (reader.NodeType != XmlNodeType.Comment))) {
             if (((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals( "item" )) && strUtil.HasText( rssItem.Title )) {
                 feed.RssItems.Add( rssItem );
                 rssItem = new RssItem();
                 isNewItem = false;
             }
             else {
                 if ((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals( "image" )) {
                     isImage = false;
                     continue;
                 }
                 if (equal( reader, "image" )) {
                     isImage = true;
                     isNewItem = false;
                     continue;
                 }
                 if (equal( reader, "item" )) {
                     isNewItem = true;
                     isImage = false;
                     continue;
                 }
                 if (reader.NodeType == XmlNodeType.Element) {
                     if (!(isNewItem || isImage)) {
                         readRssChannel( feed, reader );
                     }
                     else if (isNewItem) {
                         readRssItem( rssItem, reader );
                     }
                     else if (isImage) {
                         readRssImage( img, reader );
                     }
                 }
             }
         }
     }
     feed.RssImage = img;
     reader.Close();
     return feed;
 }
Example #3
0
 private static void readRssImage( RssImage img, XmlReader reader )
 {
     if (equal( reader, "title" )) {
         img.Title = reader.ReadString();
     }
     else if (equal( reader, "url" )) {
         img.Url = reader.ReadString();
     }
     else if (equal( reader, "link" )) {
         img.Link = reader.ReadString();
     }
     else if (equal( reader, "description" )) {
         img.Description = reader.ReadString();
     }
     else if (equal( reader, "width" )) {
         img.Width = cvt.ToInt( reader.ReadString() );
     }
     else if (equal( reader, "height" )) {
         img.Height = cvt.ToInt( reader.ReadString() );
     }
 }
Example #4
0
        public static RssChannel Create(String rssUrl)
        {
            RssChannel    feed      = new RssChannel();
            RssImage      img       = new RssImage();
            XmlTextReader reader    = new XmlTextReader(rssUrl);
            Boolean       isNewItem = false;
            Boolean       isImage   = false;
            RssItem       rssItem   = new RssItem();

            reader.MoveToContent();
            while (reader.Read())
            {
                if (!reader.Name.Equals("channel") && ((reader.NodeType != XmlNodeType.Whitespace) && (reader.NodeType != XmlNodeType.Comment)))
                {
                    if (((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals("item")) && strUtil.HasText(rssItem.Title))
                    {
                        feed.RssItems.Add(rssItem);
                        rssItem   = new RssItem();
                        isNewItem = false;
                    }
                    else
                    {
                        if ((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals("image"))
                        {
                            isImage = false;
                            continue;
                        }
                        if (equal(reader, "image"))
                        {
                            isImage   = true;
                            isNewItem = false;
                            continue;
                        }
                        if (equal(reader, "item"))
                        {
                            isNewItem = true;
                            isImage   = false;
                            continue;
                        }
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (!(isNewItem || isImage))
                            {
                                readRssChannel(feed, reader);
                            }
                            else if (isNewItem)
                            {
                                readRssItem(rssItem, reader);
                            }
                            else if (isImage)
                            {
                                readRssImage(img, reader);
                            }
                        }
                    }
                }
            }
            feed.RssImage = img;
            reader.Close();
            return(feed);
        }