Brightscript xml support – BrightSign BrightScript 2 Reference Guide User Manual
Page 16

16
BrightScript XML Support
BrightScript supports XML via two Roku Objects, and some dedicated language features.
The Roku Object roXMLElement provides support for parsing, generating, and
containing XML. In addition, the roXMLList object is often used to hold lists of
roXMLElement, and implements the BrightScript standard ifList interface as well as the
ifXMLList interface. Language features are provided via the dot operator, and the @
operator.
Dot Operator on XML
1. When applied to an roXMLElement, the dot operator returns an roXMLList of
children that match the dot operand. If no tags match, an empty list is returned
2. When applied to an roXMLList, the dot operator aggregates the results of
performing the dot operator on each roXMLElement in the list.
Attribute Operator
The @ operator can be used on an roXMLElement to return a named attribute. When
used on an roXMLList, the @ operator will return a value only if the list contains exactly
one element.
For example, if the file “example.xml” contains the following:
server="3125" farm="4" title="VNY 16R" ispublic="1" isfriend="0" server="3078" farm="4" title="hoot" ispublic="1" isfriend="0" server="3286" farm="4" title="172 • 365 :: Someone once told
isfamily="0" />
isfamily="0" />
me..." ispublic="1" isfriend="0"
Then
rsp=CreateObject(“roXMLElement”)
rsp.Parse(ReadAsciiFile(“example.xml”))
? rsp.photos.photo
Will return an roXMLList with three entries.
? rsp.photos.photo[0]