# BrightAuthor Feed Parser example

Sample brightscript parser to get you started with processing a feed with url links to media files. This parser is intended to work with BS:Connected On Demand state or BrightAuthor Classic Video Play File state.

```javascript
Sub feedParser(xmlFileName$ as String, itemsByIndex as object, itemsByTitle as Object, userVariables As Object)
	print "@feedParser"
	slog=createobject("roSystemLog")
	xml = CreateObject("roXMLElement")
		
		if not xml.Parse(ReadAsciiFile(xmlFileName$)) then 
			msg$ =  "@feedParser FAILED to read xml: " + xmlfilename$
			print msg$
			slog.sendline(msg$)
			return
		end if
		
		if type(xml.channel.item) <> "roXMLList" then 
			msg$ =  "@feedParser NOT a roXMLList: " + xmlfilename$
			print msg$
			slog.sendline(msg$)
			return
		end if

		for each itemXML in xml.channel.item
			
			ItemTitle$ = itemXML.title.GetText()
			itemUrl$ = itemXML.link.GetText()
			
			slog.sendline("@feedParser " + itemUrl$ )
			slog.sendline("@feedParser " + ItemTitle$)	
			
			itemsByIndex.push(itemUrl$)
			itemsByTitle.AddReplace(ItemTitle$, itemUrl$)
	
		next

	
end Sub
```
