Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
Hello,

I want to create rss feeds through vb.net.

The xml code of a valid rss is as shown:


<rss version="2.0">
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  >

<channel>
  <title>indiavideo2173451</title>
  <atom:link href="http://hostmyrss.com/feed/indiavideo2173451" rel="self" type="application/rss+xml" xmlns:atom="#unknown" />
  <link>http://hostmyrss.com/feed/indiavideo2173451</link>
  <description></description>
    
        <item>
        <title>How to key - Howtounlock - Zimbio</title>
        <link>http://www.zimbio.com/Howtounlock/articles/pPDb9wMet2T/How+to+key</link>
        <pubdate>Sun, 4 Jul 2010 02:40:23 -0700</pubdate>
        <guid ispermalink="true">http://www.zimbio.com/Howtounlock/articles/pPDb9wMet2T/How+to+key</guid>
        <description>What are software keys or unlock keys ? Software keys are a type of security method implemented to prevent piracy or illegal sharing of the software. Companies spend thousands of dollars to make a software. To prevent it from being pirated</description>
      </item>
      
  </channel>

</rss>



I use the following code in vb.net :

Dim xtw As New XmlTextWriter(SaveFileDialog1.FileName, Encoding.UTF8)
                xtw.WriteStartDocument()
                xtw.WriteComment("")
                xtw.WriteStartElement("rss")
                xtw.WriteAttributeString("version", "2.0")
                
                xtw.WriteStartElement("channel")
                xtw.WriteElementString("title", TextEdit1.Text)
                xtw.WriteElementString("link", TextEdit2.Text)
                xtw.WriteElementString("atom:link", "")
                xtw.WriteElementString("description", TextEdit3.Text)


                Dim i As Integer
                For i = 0 To RichTextBox1.Lines.Count - 1
                    html = http.QuickGetStr(RichTextBox1.Lines(i))
                    xtw.WriteStartElement("item")
                    xtw.WriteElementString("title", htmlUtil.GetTitle(html))
                    xtw.WriteElementString("description", htmlUtil.GetDescription(html))
                    xtw.WriteElementString("link", RichTextBox1.Lines(i))
                    xtw.WriteElementString("pubDate", Now.Date.ToString)
                    xtw.WriteElementString("guid", RichTextBox1.Lines(i))
                    xtw.WriteEndElement()
                Next

                xtw.WriteEndElement()
                xtw.WriteEndElement()
                xtw.WriteEndDocument()
                xtw.Flush()
                xtw.Close()




I am not able to get the valid xml output.
On using this with w3c rss validator I get 2 errors:

1.) I need this line : <atom:link href="http://hostmyrss.com/feed/indiavideo2173451" rel="self" type="application/rss+xml" xmlns:atom="#unknown">

how do I add that?

for more errors see : http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fballiya007.fileave.com%2Ffirst.xml

I have removed other errors.
Posted
Updated 15-Aug-10 1:04am
v3
Comments
Dalek Dave 14-Aug-10 11:01am    
Edited for Readability, Syntax and Code Block.
amit_upadhyay 14-Aug-10 11:05am    
i ignored html while posting because it damages the xml part. this way no one will understand a valid rss xml feed.
Toli Cuturicu 14-Aug-10 12:04pm    
Reason for my vote of 2
Where is the c# from the tags?
Abhishek Sur 14-Aug-10 13:27pm    
XML tags cannot be seen properly.
The problem might be because of RichTextBox1.Lines(i)
You need to use CData here.
Estys 15-Aug-10 7:05am    
corrected the XML with valid "<" and ">" tags

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900