|
|
|
|
|
- Overview
- How to?
- Create an RSS feed
- Examples
WINDEV, WEBDEV and WINDEV Mobile allow you to produce and/or consume an RSS feed (Rapid Simple Syndication). An RSS feed is used to produce (make available) a data stream in standard format. This data stream can be read (consumed) by an application. A reader of RSS feed is used to display one or more RSS feeds. Create an RSS feed To create an RSS feed: - Declare the rssStream, rssChannel and rssEntry variables.
- Describe the channel with the rssChannel properties.
- Describe the entries with the rssEntry properties.
- Add the channel then its entries into the stream.
Remarks: - A stream is made of channels. A channel is made of entries.
- We recommend that you use functions such as Add, Delete, … to handle the array of entries and the array of channels.
Examples Example for creating a RSS feed: MyStream is rssStream
MyChannel is rssChannel
MyEntry is rssEntry
MyPath is string
MyChannel.Title = "My site"
MyChannel.Description = "Example of RSS 2.0 stream"
MyChannel.UpdateDate = DateSys() + TimeSys()
MyChannel.Link = "http://www.example.org"
MyEntry.Author = "pcsoft@pcsoft.fr"
MyEntry.Description = "First news"
MyEntry.Title = "News #1"
Add(MyChannel.Entry, MyEntry)
Add(MyStream.Channel, MyChannel)
MyPath = CompleteDir(fCurrentDir()) + "Rss.xml"
rssSave(MyStream, MyPath)
IF NOT ShellExecute(MyPath) THEN
Error("ShellExecute('" + MyPath + "'). '" + ErrorInfo() + "'")
END
Please note In this example, additions made with the Add function must be made last to manipulate the desired element. You also have the ability to use the following code: MyStream is rssStream
ChannelNum is int
EntryNum is int
MyPath is string
MyPath = CompleteDir(fCurrentDir()) + "Rss.xml"
ChannelNum = 1
ChannelNum = Add(MyStream.Channel)
MyStream.Channel[ChannelNum].Title = "My site"
MyStream.Channel[ChannelNum].Description = "Example of RSS 2.0 stream"
MyStream.Channel[ChannelNum].PublicationDate = Today()
MyStream.Channel[ChannelNum].Link = "http://www.example.org"
EntryNum = Add(MyStream.Channel[ChannelNum].Entry)
MyStream.Channel[ChannelNum].Entry[EntryNum].Title = "First news"
MyStream.Channel[ChannelNum].Entry[EntryNum].Description = "News #1"
MyStream.Channel[ChannelNum].Entry[EntryNum].Link = "http://www.example.org"
MyStream.Channel[ChannelNum].Entry[EntryNum].PublicationDate = Today()
EntryNum = Add(MyStream.Channel[ChannelNum].Entry)
MyEntry is rssEntry dynamic = MyStream.Channel[ChannelNum].Entry[EntryNum]
MyEntry.Title = "Second news"
MyEntry.Description = "News #2"
MyEntry.Link = "http://www.example.org"
MyEntry.PublicationDate = Today()
rssSave(MyStream, MyPath)
IF NOT ShellExecute(MyPath) THEN
Error("ShellExecute('" + MyPath + "'). '" + ErrorInfo() + "'")
END
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|