I am building a channel that call two xml files, the first one contain the links for the contents that will be shown in every row, the first call it work fine because i am using a static url
url = CreateObject("roUrlTransfer")
url.SetUrl("http://theRowsContents.xml")
rsp = url.GetToString()
responseXML = ParseXML(rsp)
responseXML = responseXML.GetChildElements()
'responseArray = responseXML.GetChildElements()
result = []
for each xmlItem in responseXML
item = {}
item.TITLE = xmlItem.getAttributes().title
item.ContentList = GetApiArray(xmlItem.getAttributes().feed)
result.push(item)
end for
but when i pass the second url to fetch the contents it wont work
Function GetApiArray(url as String)
newXfer = CreateObject("roUrlTransfer")
newXfer.SetUrl(url)
response = newXfe.GetToString()
responseXML = ParseXML(response)
responseXML = responseXML.GetChildElements()
responseArray = responseXML.GetChildElements()
and this is the log
> Suspending threads... Thread selected: 0* pkg:/source/main.brs(112)
> responseXML = responseXML.GetChildElements()
>
> Current Function: 106: Function GetApiArray(url as String) 107:
> newXfer = CreateObject("roUrlTransfer") 108: newXfer.SetUrl(url)
> 109: response = newXfer.GetToString() 110: 111:
> responseXML = ParseXML(response) 112:* responseXML =
> responseXML.GetChildElements() 113: responseArray =
> responseXML.GetChildElements() 114: 115: result = [] 116:
> 'Dot' Operator attempted with invalid BrightScript Component or
> interface reference. (runtime error &hec) in pkg:/source/main.brs(112)
> 112: responseXML = responseXML.GetChildElements() Backtrace:
> #2 Function getapiarray(url As String) As Dynamic file/line: pkg:/source/main.brs(112)
> #1 Function makerequest() As Dynamic file/line: pkg:/source/main.brs(54)
> #0 Function runuserinterface() As Void file/line: pkg:/source/main.brs(15) Local Variables: url roString
> (2.1 was String) refcnt=2 val:"https://contentsFeed.xml" global
> Interface:ifGlobal m roAssociativeArray refcnt=4
> count:1 newxfer roUrlTransfer refcnt=1 response
> roString (2.1 was String) refcnt=1 val:"" responsexml Invalid
> responsearray <uninitialized> result <uninitialized> xmlitem
> <uninitialized> itemaa <uninitialized> item
> <uninitialized> Threads: ID Location
> Source Code 0* pkg:/source/main.brs(112) responseXML
> = responseXML.GetChildElements() *selected
>
> Brightscript Debugger>
so what i am doing wrong ?
You have a typo on line 109 ;)
You are using newXfe
instead of newXfer
.
See the error:
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/source/main.brs(109)
That's because newXfe
is uninitialized (obviously).