...
The following examples illustrate how XML elements are parsed in BrightScript:
Code Block |
---|
<tag1>This is example text</tag1> |
...
The following is an example subroutine to print out the contents of an roXMLElement tree:
Code Block |
---|
PrintXML(root, 0) Sub PrintXML(element As Object, depth As Integer) print tab(depth*3);"Name: ";element.GetName() if not element.GetAttributes().IsEmpty() then print tab(depth*3);"Attributes: "; for each a in element.GetAttributes() print a;"=";left(element.GetAttributes()[a], 20); if element.GetAttributes().IsNext() then print ", "; end for print end if if element.GetText()<>invalid then print tab(depth*3);"Contains Text: ";left(element.GetText(), 40) end if if element.GetChildElements()<>invalid print tab(depth*3);"Contains roXMLList:" for each e in element.GetChildElements() PrintXML(e, depth+1) end for end if print end sub |