jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2010
04:42 PM
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
<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!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
3 REPLIES 3

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2010
04:57 PM
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.
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2010
05:13 PM
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"]
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2010
06:07 PM
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
Thanks!
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!