jandre
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:02 PM
& (ampersand) symbol issue with xml parsing
Looks like there is an issue parsing xml which has ampersand (&) symbol.
for eg, in the following xml when I use "Elizabeth & Gilbert" instead of "Elizabeth Gilbert " I get 'Cant parse feed " Error.
<item sdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/ElizabethGilbert.jpg" hdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/ElizabethGilbert.jpg">
<title>Elizabeth & Gilbert on nurturing creativity</title>
<contentId>10051</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>mp4</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.mp4</streamUrl>
</media>
<synopsis>Elizabeth Gilbert muses on the impossible things we expect from artists and geniuses -- and shares the radical idea that, instead of the rare person 'being' a genius, all of us 'have' a genius. It's a funny, personal and surprisingly moving talk.</synopsis>
<genres>Creativity</genres>
<runtime>1172</runtime>
</item>
Any way to get around this situation?
Thanks!
for eg, in the following xml when I use "Elizabeth & Gilbert" instead of "Elizabeth Gilbert " I get 'Cant parse feed " Error.
<item sdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/ElizabethGilbert.jpg" hdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/ElizabethGilbert.jpg">
<title>Elizabeth & Gilbert on nurturing creativity</title>
<contentId>10051</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>mp4</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.mp4</streamUrl>
</media>
<synopsis>Elizabeth Gilbert muses on the impossible things we expect from artists and geniuses -- and shares the radical idea that, instead of the rare person 'being' a genius, all of us 'have' a genius. It's a funny, personal and surprisingly moving talk.</synopsis>
<genres>Creativity</genres>
<runtime>1172</runtime>
</item>
Any way to get around this situation?
Thanks!
9 REPLIES 9
evilmax17
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:04 PM
Re: & (ampersand) symbol issue with xml parsing
Try this:
<title>Elizabeth & Gilbert on nurturing creativity</title>
My Roku Channels:
Viddler - viddler.com
Tested Fan - tested.com | Jamie & Adam
This is my next - theverge.com
1080p Showcase - RIP
Whiskey Media - RIP
======================
http://www.binarymoustache.com
Viddler - viddler.com
Tested Fan - tested.com | Jamie & Adam
This is my next - theverge.com
1080p Showcase - RIP
Whiskey Media - RIP
======================
http://www.binarymoustache.com

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:10 PM
Re: & (ampersand) symbol issue with xml parsing
Ampersands need to be encoded in XML regardless of the parser.
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)
jandre
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:16 PM
Re: & (ampersand) symbol issue with xml parsing
Thanks that works. however I am wondering if this can be fixed at the sdk level, the reason is I am pulling a lot of data from the backend and I dont know where all the places I have the & symbol and escaping/encoding the symbol everytime going to be an issue. Also I have secure video URLs with & symbols in it causing some problems because of this parsing issue.
Thanks,
Thanks,
jandre
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:22 PM
Re: & (ampersand) symbol issue with xml parsing
"TheEndless" wrote:
Ampersands need to be encoded in XML regardless of the parser.
yes...looks like that is the rule 🙂
Thanks!
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:38 PM
Re: & (ampersand) symbol issue with xml parsing
So if the XML has an ampersand, it is going to fail parsing. Could one perhaps use regex to search and replace ampersands with & before parsing?
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!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:43 PM
Re: & (ampersand) symbol issue with xml parsing
"jbrave" wrote:
So if the XML has an ampersand, it is going to fail parsing. Could one perhaps use regex to search and replace ampersands with & before parsing?
One could if they were positive there were no other properly encoded characters in the XML (or one had the patience to figure out the regex to detect the difference).
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)
mchasal
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
08:57 PM
Re: & (ampersand) symbol issue with xml parsing
I believe an unescaped & literal violates the spec for xml and even html, so the backend should be fixed to not do that. Php has a function to do so if you are using that: http://php.net/manual/en/function.htmlspecialchars.php Just run any text fields that might contain special characters through a function like that to escape them.
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011
09:52 PM
Re: & (ampersand) symbol issue with xml parsing
"TheEndless" wrote:"jbrave" wrote:
So if the XML has an ampersand, it is going to fail parsing. Could one perhaps use regex to search and replace ampersands with & before parsing?
One could if they were positive there were no other properly encoded characters in the XML (or one had the patience to figure out the regex to detect the difference).
Zero width negative lookahead matching makes the regex to find and replace rogue ampersands somewhat trivial. Incorrectly encoded > and < are a bit harder...
Match: &(?!\S+;)
Replace: &
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2011
06:24 AM
Re: & (ampersand) symbol issue with xml parsing
Ampersands aren't the only symbols you can/will have issues with. I'm not sure what platform/language you're using, but it would behoove you to make sure that you properly encode all attributes and elements. We use .NET -- and therefore we use Microsoft's AntiXSS library to properly encode all XML attributes and elements. You will run into issues with internationalization (UTF-8 symbols) and also with other symbols ('<', '>', etc.) if you don't do that.