Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tintumonkb
Visitor

xml convertor to differnet xml format

i have a xml with video on demand videos, which DOESNOT support on videoplayer.zip SDK file
im looking for to converter that convert my xml to the supported xml style in roku,
whenever new videos comesup, it automatically have to convert in to the supported xml. is it possible ?
any one have idea ?please share your ideas, and help me out, i appreciate.
0 Kudos
5 REPLIES 5
destruk
Binge Watcher

Re: xml convertor to differnet xml format

If you're talking about the tag names, it'd be easer to change the code in showfeed.brs to match your xml rather than 'converting' existing xml every time it downloads.
The Videoplayer sample SDK has showfeed.brs


'fetch all values from the xml for the current show
item.hdImg = validstr(curShow@hdImg)
item.sdImg = validstr(curShow@sdImg)
item.ContentId = validstr(curShow.contentId.GetText())
item.Title = validstr(curShow.title.GetText())
item.Description = validstr(curShow.description.GetText())
item.ContentType = validstr(curShow.contentType.GetText())
item.ContentQuality = validstr(curShow.contentQuality.GetText())
item.Synopsis = validstr(curShow.synopsis.GetText())
item.Genre = validstr(curShow.genres.GetText())
item.Runtime = validstr(curShow.runtime.GetText())
item.HDBifUrl = validstr(curShow.hdBifUrl.GetText())
item.SDBifUrl = validstr(curShow.sdBifUrl.GetText())
item.StreamFormat = validstr(curShow.streamFormat.GetText())
if item.StreamFormat = "" then 'set default streamFormat to mp4 if doesn't exist in xml
item.StreamFormat = "mp4"
endif
0 Kudos
tintumonkb
Visitor

Re: xml convertor to differnet xml format

my xml is starting with
<rsp>
<code id="1">
<channelList>

in videoplayer its <feed>
<endIndex>4</endIndex>
<item
0 Kudos
tintumonkb
Visitor

Re: xml convertor to differnet xml format

my xml is looks like this,
<rsp>
<code id="1">
<channelList>
<channel id="2004" ContentType="episode" SDPosterUrl="http://downhillmoney.com/wp-content/uploads/2014/04/video-to-promote-yourself.jpg" HDPosterUrl="http://downhillmoney.com/wp-content/uploads/2014/04/video-to-promote-yourself.jpg" ShortDescriptionLine1="video garden" Description="video garden" Title="video garden" urls="http://techslides.com/demos/sample-videos/small.mp4" bannerad="" isPreroll="0" SDTickerUrl="http://ex.InstantTvChannel.com/ad-sd-g.png" HDTickerUrl="http://ex.InstantTvChannel.com/ad-hd-g.png" isTickerShow="0" isWaterMark="0" isCustomPlayer="0" waterMarkTime="837" Packid="545" Userid="" isUserLog="0"/>
</channelList>
</code>
</rsp>
0 Kudos
tintumonkb
Visitor

Re: xml convertor to differnet xml format

Do you know any other ways, other than editing show feed.brs file.
Any software that can change my XML tag to the supported XML tag?
0 Kudos
destruk
Binge Watcher

Re: xml convertor to differnet xml format

Notepad would allow you to open the xml file and do a search/replace -- or you could do that with the search/replace function in generalutils.brs before you parse the xml.
Note - string replacement can be extremely slow on roku with a large xml or json file as your source.

from generalutils.brs

'******************************************************
'Replace substrings in a string. Return new string
'******************************************************
Function strReplace(basestr As String,oldsub As String,newsub As String) As String
newstr=""
i=1
While i<=Len(basestr)
x=Instr(i,basestr,oldsub)
If x=0
newstr=newstr+MID(basestr,i)
Exit While
End If
If x>i
newstr=newstr+MID(basestr,i,x-i)
i=x
End If
newstr=newstr+newsub
i=i+Len(oldsub)
End While
Return newstr
End Function


basestr would be rsp, or your downloaded xml prior to parsexml. NewSub would be what you need the tag name to be, oldsub would be what the tag name is now (when you download it)
0 Kudos