360tv
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014
11:52 AM
Trouble getting an XML Element
I have the following...
I need to get the url of the second url attribute.
imagesXML.channel.item.count() works but media@content or media.content@url wont. media:content@url is invalid syntax (of course). I cannot change the XML.
<imagesXML>
<channel>
<item><media:content url="http://s3.amazonaws.com/bucket/1.jpg" medium="image"/></item>
<item><media:content url="http://s3.amazonaws.com/bucket/2.jpg" medium="image"/></item>
<item><media:content url="http://s3.amazonaws.com/bucket/3.jpg" medium="image"/></item>
</channel>
</imagesXML>
I need to get the url of the second url attribute.
imagesXML.channel.item.count() works but media@content or media.content@url wont. media:content@url is invalid syntax (of course). I cannot change the XML.
3 REPLIES 3

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014
12:35 PM
Re: Trouble getting an XML Element
You'll need to user getNamedElement() to get nodes with namespaces. You may need to break it into multiple statements, but something like this should work:
xml.channel.item[0].getNamedElements("media:content")[0]@url
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)
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014
04:20 PM
Re: Trouble getting an XML Element
"TheEndless" wrote:
You'll need to user getNamedElement() to get nodes with namespaces. You may need to break it into multiple statements, but something like this should work:xml.channel.item[0].getNamedElements("media:content")[0]@url
Actually can do it even simpler, because ifXMLList supports getNamedElements() just like ifXMLElement does (i.e. no need to zero-in on the exact element just yet)
xml.channel.item.getNamedElements("media:content")But then will still have to add `[idx]@url` for the specific attribute as needed - because GetAttributes() does not work the same way for ifXMLList, so one cannot do
xml.channel.item.getNamedElements("media:content").getAttributes().url 'No good
xml.channel.item.getNamedElements("media:content")@url 'No good
'but this will do
xml.channel.item.getNamedElements("media:content")[idx]@url 'OK with single row
I like to give credit to roXML when it deserves it: it has some... affordances 🙂
360tv
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2014
09:40 AM
Re: Trouble getting an XML Element
Thanks a lot! Works perfectly.