<?xml version="1.0" encoding="UTF-8" ?>
<schedule>
<DAY attr="2014-11-4">
<time attr="06:00 am">
<show name="My Show">
<sid>6978</sid>
<network>My Channel</network>
<title>Season 17, Episode 277</title>
<ep>17x277</ep>
<link>http://www.mytv.com/My Show/episodes/1065649497</link>
</show>
</time>
</DAY>
</schedule>
readxml=ReadAsciiFile("tmp:/status.temp")
xmlfilelist = CreateObject("roXMLElement")
if xmlFileList.Parse(readxml) then
For Each day in xmlFileList.schedule
network = day.network.GetText()
Print"NETWORK. . "network
Next
End If
<?xml version="1.0" encoding="UTF-8" ?>
<schedule>
<DAY attr="2014-11-4">
<time attr="06:00 am">
<show name="My Show">
<sid>6978</sid>
<network>My channel</network>
<title>Season 17, Episode 277</title>
<ep>17x277</ep>
</show>
</time>
</DAY>
</schedule>
x.day@attr
x.day.time@attr
x.day.time.show@name
x.day.time.show.network.GetText()
xmlfilelist = CreateObject("roXMLElement")
xxml=xmlFileList.Parse(readxml)
if xmlFileList.Parse(readxml) then
PRINT"PASSED. . ."
day=xmlfilelist.day@attr
time=xmlfilelist.time@attr
show=xmlfilelist.day.time.show@name
network=xmlfileList.day.time.show.network.GetText()
print day
print time
print show
print network
END IF
BrightScript Debugger> x.parse("<schedule><DAY attr='2014-11-4'> <time attr='06:00 am'> <show name='My Show'> <sid>6978</sid> <network>My channel</network> <title>Season 17, Episode 277</title> <ep>17x277</ep> </show> </time></DAY></schedule>")
BrightScript Debugger> ? x.day@attr
2014-11-4
BrightScript Debugger> ? x.day.time@attr
06:00 am
BrightScript Debugger> ? x.day.time.show@name
My Show
BrightScript Debugger> ? x.day.time.show.network.GetText()
My channel
daylist=[]
xmlfilelist = CreateObject("roXMLElement")
for each DAY in xmlFileList
daylist.Push({
DAY: {DAY: xmlfilelist.day@attr}
})
End For
for each day in xmlFileList.DAY: 'this returns a list of DAYs; xmlFileList is not really a list but roXmlElement
for each time in day.time:
for each show in time.show:
'do the due
end for
end for
end for
BrightScript Debugger> ? {a: 1}The last two are confusing, i agree - there is no hint that what is output is a vector and not scalar.
a: 1
BrightScript Debugger> ? [ 1 ]
1
BrightScript Debugger> ? [ {a: 1} ]
<Component: roAssociativeArray>