Roku:带有动态url的roUrlTransfer返回空



我正在构建一个通道,该通道调用两个xml文件,第一个文件包含将在每行中显示的内容的链接,第一个调用工作正常,因为我使用的是静态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

但是当我通过第二个url来获取内容时,它不会工作

Function GetApiArray(url as String)
newXfer = CreateObject("roUrlTransfer")
newXfer.SetUrl(url)
response = newXfe.GetToString()
responseXML = ParseXML(response)
responseXML = responseXML.GetChildElements()
responseArray = responseXML.GetChildElements()

这是日志

> 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>

那么我做错了什么?

您在第109行有一个拼写错误;(

您使用的是newXfe而不是newXfer

查看错误:

试图使用无效的BrightScript组件或接口引用。(运行时错误&hec(在pkg:/source/main.brs(109(中

这是因为newXfe未初始化(显然(。

相关内容

  • 没有找到相关文章

最新更新