...
The following examples illustrate how XML elements are parsed in BrightScript:
Code Block |
---|
<tag1>This is example text</tag1> |
- Name = tag1
- Attributes = Invalid
- Body = roString containing "This is example text"
...
To generate XML content, create an roXMLElement and call the SetBody()
and and SetName()
methods methods to build it, then it–then call the GenXML()
method method to generate it.
Code Block | ||
---|---|---|
| ||
root.SetName("myroot") root.AddAttribute("key1","value1") root.AddAttribute("key2","value2") ne=root.AddBodyElement() ne.SetName("sub") ne.SetBody("this is the sub1 text") ne=root.AddBodyElement() ne.SetName("subelement2") ne.SetBody("more sub text") ne.AddAttribute("k","v") ne=root.AddElement("subelement3") ne.SetBody("more sub text 3") root.AddElementWithBody("sub","another sub (#4)") PrintXML(root, 0) print root.GenXML(false) |
ifXMLElement
GetBody() As Object
GetAttributes() As Object
GetName() As String
GetText() As String
GetChildElements() As Object
GetNamedElements(a As String) As Object
GetNamedElementsCi(a As String) As Object
SetBody(a As Object)
Generates an roXMLList for the body if needed. The method then adds the passed item (which should be an roXMLElement tag).
AddBodyElement() As Object
AddElement(a As String) As Object
AddElementWithBody(a As String, b As Object) As Object
AddAttribute(a As String, b As String)
SetName(a As String)
Parse(a As String) As Boolean
...
Generates XML content. This method takes a single Boolean parameter, indicating whether or not the XML should have an <?xml …>
tag at the top.
Clear() As Void
GenXMLHdr(a As String) As String
IsName(a As String) As Boolean
HasAttribute(a As String) As Boolean
ParseFile(a As String) As Boolean
...
The following is an example subroutine to print out the contents of an roXMLElement tree:
...