Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Level 8

colon in xml tag?

Anyone know how to get and parse an xml tag that has a colon in it like this:

<media:thumbnail xmlns:media='http://something.something.com/mrss/' url='http://blahblablah.com' width='72' height='72' />

Weird thing is that the data is inside the tag, not inbetween <> and </> like normal tags...

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
3 REPLIES 3\
TheEndless
Level 9

Re: colon in xml tag?

I'm not sure what you mean by "weird thing" but...

The part before the colon (media) is the namespace as defined by the "xmlns:media" attribute. It's essentially a way of making a common tag name unique, and associate it with a specific data source. I haven't parsed an XML document with namespaces in BrightScript, but I'd think you would be able to get it with GetNamedElements().

The values I think you're talking about (url, width, and height) are attribute values. You'd access them using @. (ex. xmlElement@url, xmlElement@width, etc). There are examples in the "working with XML" section of the BrightScript reference.
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
RokuChris
Roku Employee
Roku Employee

Re: colon in xml tag?

"jbrave" wrote:
Anyone know how to get and parse an xml tag that has a colon in it like this:

<media:thumbnail xmlns:media='http://something.something.com/mrss/' url='http://blahblablah.com' width='72' height='72' />


  • To access elements with namespaces, use elementArray = GetNamedElements("media:thumbnail")

  • To access attributes without namespaces, you can use the @ operator. element@url

  • For attributes with namespaces, you would need to say element.GetAttributes()["xmlns:media"]
0 Kudos
jbrave
Level 8

Re: colon in xml tag?

By weird I meant I hadn't encountered this style of before in the parsing projects I've undertaken. Anyway, got it working using GetNamedElements("media:thumbnail") and then GetAttributes()

Thanks!

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos