greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
09:32 AM
XML.Parse() and escaped characters
When parsing an XML data block from a user, the parse() function failed when it came across this sequence.
<tag>Some Title </tag>
I think that the "&x5;" is an invalid escape sequence (should have two digits) BUT should the parse() fail ?
I reran the block of data and changed the &x5; to &x50; and the block was able to be decoded.
<tag>Some Title </tag>
I think that the "&x5;" is an invalid escape sequence (should have two digits) BUT should the parse() fail ?
I reran the block of data and changed the &x5; to &x50; and the block was able to be decoded.
9 REPLIES 9
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
11:07 AM
Re: XML.Parse() and escaped characters
If the XML is invalid, why shouldn't the parse fail?
You can check the XML against a validator like http://www.w3schools.com/xml/xml_validator.asp. I believe single digit hex escapes will be rejected.
--Mark
You can check the XML against a validator like http://www.w3schools.com/xml/xml_validator.asp. I believe single digit hex escapes will be rejected.
--Mark
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
11:22 AM
Re: XML.Parse() and escaped characters
In this case is not the XML, it's the content.
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
01:06 PM
Re: XML.Parse() and escaped characters
I don't understand what you mean by "content" here. Do you mean the character is in character data rather than in a tag? It's still part of the XML document and must be properly encoded. If you have an XML document that validates cleanly in a validator but causes parse() to fail, please post it.
--Mark
--Mark
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
01:24 PM
Re: XML.Parse() and escaped characters
Validator says No errors ! It fails on "<dc:title>SONY&#5;1</dc:title>"
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1"><Result><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:arib="urn:schemas-arib-or-jp:elements-1-0/" xmlns:dtcp="urn:schemas-dtcp-com:metadata-1-0/" xmlns:pv="http://www.pv.com/pvns/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="0$3$28I80394" parentID="0$3$28" restricted="1"><dc:title>SILVER_SURFER_VOL_025</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I80650" parentID="0$3$28" restricted="1"><dc:title>SILVER_SURFER_VOL_031</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I80906" parentID="0$3$28" restricted="1"><dc:title>SILVER_SURFER_VOL_032</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I81162" parentID="0$3$28" restricted="1"><dc:title>SILVER_SURFER_VOL_033</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I81418" parentID="0$3$28" restricted="1"><dc:title>SILVER_SURFER_VOL_034</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I122634" parentID="0$3$28" restricted="1"><dc:title>SOLDIER_16X9LB_SIDE_B_NA1</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I36618" parentID="0$3$28" restricted="1"><dc:title>Sons.of.Anarchy.S04E01.Out.HDTV.XviD-ASAP</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I112138" parentID="0$3$28" restricted="1"><dc:title>SONY&#5;1</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I81930" parentID="0$3$28" restricted="1"><dc:title>SPARTAN [2004][ENG][AC3][DVDRIP-M333]-FLAWL3SS</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I68362" parentID="0$3$28" restricted="1"><dc:title>SPYLOVE1</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I411402" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x01 - The Cage</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I411658" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x02 - Where No Man Has Gone Before</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I411914" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x03 - The Corbomite Maneuver</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I412170" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x04 - Mudd&apos;s Women</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I412426" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x05 - The Enemy Within</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I412682" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x06 - The Man Trap</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I412938" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x07 - The Naked Time</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I413194" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x08 - Charlie X</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I413450" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x09 - Balance of Terror</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I413706" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x10 - What are Little Girls Made of</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I397322" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x11 - Dagger of the Mind</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I413962" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x12 - Miri</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I414218" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x13 - The Conscience of the King</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I414474" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x14 - The Galileo Seven</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item><item id="0$3$28I414730" parentID="0$3$28" restricted="1"><dc:title>Star Trek - 1x15 - Court Martial</dc:title><upnp:class>object.item.videoItem.movie</upnp:class></item></DIDL-Lite></Result><NumberReturned>25</NumberReturned><TotalMatches>632</TotalMatches><UpdateID>3</UpdateID></u:BrowseResponse></s:Body></s:Envelope>
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
01:44 PM
Re: XML.Parse() and escaped characters
Hold on, you've posted a valid XML string that has invalid XML embedded in it. So are you saying that the string you posted fails when you parse it, or is it the embedded XML (the one with the ) that fails? The main XML should parse correctly, in both Brightscript and in the validator. The embedded XML should fail both.
--Mark
--Mark
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
01:52 PM
Re: XML.Parse() and escaped characters
Sorry, let me get the value of the returned results.
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
02:03 PM
Re: XML.Parse() and escaped characters
Ok, he fails on the embedded XML with "XML Parsing Error: reference to invalid character number" !
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
08:36 PM
Re: XML.Parse() and escaped characters
"greubel" wrote:
<tag>Some Title </tag>
I think that the "&x5;" is an invalid escape sequence (should have two digits) BUT should the parse() fail ?
What, why two digits - i dont get it. The following passes just fine through the validator (http://validator.w3.org/check😞
<?xml version="1.0" ?>
<tag>Some Title 	</tag>
does it xml.parse()?
TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2013
09:11 PM
Re: XML.Parse() and escaped characters
"EnTerr" wrote:"greubel" wrote:
<tag>Some Title </tag>
I think that the "&x5;" is an invalid escape sequence (should have two digits) BUT should the parse() fail ?
What, why two digits - i dont get it. The following passes just fine through the validator (http://validator.w3.org/check😞<?xml version="1.0" ?>
<tag>Some Title 	</tag>
does it xml.parse()?
I suspect 9 is a special case, because it's a whitespace character that can be represented in ASCII/UTF-7/UTF-8/etc (it's a tab). 5 cannot. The fact that it's only a single digit is inconsequential. Adding a zero just converts it to a completely different character (capital P).
xml.Parse() and the validator can both parse 	. Neither can parse .
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)