I'm at home so I may make mistakes but I'll lay down the basic concept. Fair warning though, you will need to take this concept and expand on it for complicated sets of data.
b> THE CRAZY BUGGERS DID IT! /> N. Korea launches nuke at US but it failed to detonate. N. Korea attempted to use tinfoil as a replacement for uranium.
Here's an example RSS item. We will use the description for the crawl.
Your scene will contain two text objects. On the bottom of the screen will be the crawl item which I'll name 'CRAWL'. The other will collect the data from the RSS which I'll name 'INPUT'. INPUT will not be visible. Connect INPUT to the RSS. Right click on INPUT and edit the script.
On the top of the script window you will see some items we can access. You should see something like
Text imported as textobject. 'Text' is the data that has been collected from the RSS. 'Scene' will give you access to other objects in your scene. Time to start writing the script.
Dim SEGMENTS(2) as string
We want to remove the headline and extra code. This creates a new String variable to temporarily hold your text. It is split into two segments. We will store the headline in the first segment and our description in the second segment.
Dim FINALTEXT as String
This is wherethe parsed text will be stored.
Dim FINALOUTPUT as xpTextObject
This will be connected to CRAWL and replace CRAWLS text with your parsed text.
if InString(Text, "/>",0) > 0 then
This will check how many times "/>" shows up in the feed. It'll be used as a safeguard just in case the feed format changes.
Text is the RSS data.
0 is where you would like to start the search. We want to start from the first character so we'll enter '0'
SEGMENTS=SplitString(Text, "/>", 0)
This will now search your feed for the first instance of "/>" and store each part in their respective segment of the string.
FINALTEXT = Segments(1)
When selecting an item, '0' is considered the first item. We just took the second item containing the description, (1), and applied it to our FINALTEXT string.
else
FINALTEXT=""
end if
This will complete the If statement being used as a safeguard. If "/>" doesn't show up in your feed, something has changed. I chose to display nothing. You could also use FINALTEXT=Text to show the unedited rss data.
scene.getTextObjectByName("CRAWL", FINALOUTPUT)
This will find the CRAWL textobject and allow you to change it's input via FINALOUTPUT
FINALOUTPUT.text=FINALTEXT
FInally, you apply your parsed text to CRAWL.
-----------------------------------------------------------------------------------------
The full script will look something like this:
Dim SEGMENTS(2) as string
Dim FINALTEXT as String
Dim FINALOUTPUT as xpTextObject
if InString(Text, "/>",0) > 0 then
SEGMENTS=SplitString(Text, "/>", 0)
FINALTEXT = Segments(1)
else
FINALTEXT=""
end if
Scene.getTextObjectByName("CRAWL", FINALOUTPUT)
FINALOUTPUT.text=FINALTEXT
_______________________________________________________________
Right now I'm creating a script to show the river levels during flood season. I had to retrieve the current river level, the projected flood level, and the date at which the river will crest. I also needed to add my own text to title each piece of data. I created 3 strings to hold my final data. FINALTEXT1, FINALTEXT2, FINALTEXT3.
First I cut off the garbage before the current water level and applied the remaining data, SEGMENTS(1), to FINALTEXT1. I then reused SEGMENTS to split everything after the current levels using FINALTEXT1 as my source.
SEGMENTS=SplitString(FINALTEXT1, "-", 0)
Finally I reapplied SEGMENTS(0) (which now contains only the current levels) to FINALTEXT1 but added my own text to describe the data.
FINALTEXT1 = "Current Levels: " + SEGMENTS(0)+"ft"
I also had to check that the projected flood levels and the date at which the crest will occur were available, and display "N/A" if they were not. I reused SEGMENTS every time I needed to split text and temporarily store the segments.
[I]Using 'if' statements: [/I]
FINALTEXT2 = " * Projected: " + SEGMENTS(0) + "ft"
[I]or[/I]
FINALTEXT2 = " * Projected: N/A"
[I]AND[/I]
FINALTEXT3 = ", " + SEGMENTS(0)
[I]or[/I]
FINALTEXT3 = ""
Finally I applied all three parts to CRAWL.
FINALOUTPUT.Text= FINALTEXT1 + FINALTEXT2 + FINALTEXT3
__________________________________________
Again, I probably made some minor mistakes here and there but this is the basic logic behind it.
#XPression