Forum Discussion

vaxace's avatar
vaxace
Binge Watcher
15 years ago

roXMLElement GetBody() and GetchildElement() methods

I've finally gotten around to trying to consume some XML from within BrightScript.
The documentation on the roXMLElement object is a bit light.

Can someone explain to me the difference between roXMLElement.GetBody() and roXMLElement.GetChildElements()?

They seem to be used interchangeably in the VideoPlayer sample.

Thanks,

D.

6 Replies

  • "vaxace" wrote:
    I've finally gotten around to trying to consume some XML from within BrightScript.
    The documentation on the roXMLElement object is a bit light.

    Can someone explain to me the difference between roXMLElement.GetBody() and roXMLElement.GetChildElements()?

    They seem to be used interchangeably in the VideoPlayer sample.

    Thanks,

    D.


    I just started working with this too, last night. I think GetBody(), along with GetText() gives you the contents of the element in string form, which GetChildElements() returns an roXMLList or roXMLElement if there's only one.
  • If I'm remembering correctly, I believe GetChildElements() actually returns and array of roXMLElements instead of an roXMLList as you might expect.
  • vaxace's avatar
    vaxace
    Binge Watcher
    Actually, I just tested it in the debugger.
    They both return an roXMLList.

    Go figure :?

    D.
  • "vaxace" wrote:
    Actually, I just tested it in the debugger.
    They both return an roXMLList.

    Go figure :?

    D.

    Hrmm.. I wonder if it was GetNamedElements() that returned an array... I know I ran across one of the roXMLElement methods that returned an array. I swear! 😛
  • GetChildElements() reurns an roXMLList. If there are no children, it returns an empty list.

    GetBody() returns an roXMLList if the body is not a leaf. If the body is a leaf node, it returns a string.

    --Kevin