Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vaxace
Binge Watcher

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.
0 Kudos
6 REPLIES 6
kbenson
Visitor

Re: roXMLElement GetBody() and GetchildElement() methods

"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.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
TheEndless
Channel Surfer

Re: roXMLElement GetBody() and GetchildElement() methods

If I'm remembering correctly, I believe GetChildElements() actually returns and array of roXMLElements instead of an roXMLList as you might expect.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
vaxace
Binge Watcher

Re: roXMLElement GetBody() and GetchildElement() methods

Actually, I just tested it in the debugger.
They both return an roXMLList.

Go figure :?

D.
0 Kudos
TheEndless
Channel Surfer

Re: roXMLElement GetBody() and GetchildElement() methods

"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! 😛
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuKevin
Visitor

Re: roXMLElement GetBody() and GetchildElement() methods

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
0 Kudos
vaxace
Binge Watcher

Re: roXMLElement GetBody() and GetchildElement() methods

Ahh. A subtle, but distinct difference.

Thanks!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.