PDA

View Full Version : [Solved] Ampersand & :: Grid Paging w/ XML Datasource.



cluettr
5 Jul 2007, 4:45 PM
This may have already been covered, but....

I wanted to post this to hopefully save someone the trouble I went through today. When populating a grid with data keep in mind that at least one character may cause issues.

Today I was cycling through my paging grid and it would stop on particular pages. I changed my limits to something very small (5 records) and using Firefox I examined the request response when it died. It turns out that anytime you have an '&' it will die. Encoding it as %26 is not what you want since this isn't URL encoding. &amp obviosuly will not work either. I'm not entirely sure what the resolution here is here. There may even be some method which might correct this and I'm sure one of the Experts will let us know. I merely removed them from all records.

Below is an example... see character in <title>6506 MOD 2 & 16 RESETTING</title>




<?xml version="1.0"?>
<Items>
<Request>
<IsValid></IsValid>
<ItemSearchRequest>
<Author>##### #. #####, ##### ##### ##### #####</Author>
<Location>######, Massachusetts</Location>
<Phone>(617) ### - ###</Phone>
</ItemSearchRequest>
</Request>
<TotalResults>424</TotalResults>
<TotalPages>data here</TotalPages>
<Item>
<RMA>81843411</RMA>
<DetailPageURL>none</DetailPageURL>
<ItemAttributes>
<createdate>2007-06-18 14:03:23</createdate>
<rma_number>81843411</rma_number>
<service_request>606231775</service_request>
<device></device>
<title>SVO :: r1318711 :: CYVLMDAIZ-UCD10S1 POWER SUPPLY 2 PROBLEM DETECTED ON BROWSER</title>
</ItemAttributes>
</Item>
<Item>
<RMA>81843231</RMA>
<DetailPageURL>none</DetailPageURL>
<ItemAttributes>
<createdate>2007-06-18 12:12:05</createdate>
<rma_number>81843231</rma_number>
<service_request>606230757</service_request>
<device></device>
<title>SVO 06/18/2007</title>
</ItemAttributes>
</Item>
<Item>
<RMA>81842262</RMA>
<DetailPageURL>none</DetailPageURL>
<ItemAttributes>
<createdate>2007-06-16 16:04:59</createdate>
<rma_number>81842262</rma_number>
<service_request>606226791</service_request>
<device></device>
<title>SVO 06/16/2007</title>
</ItemAttributes>
</Item>
<Item>
<RMA>81841648</RMA>
<DetailPageURL>none</DetailPageURL>
<ItemAttributes>
<createdate>2007-06-15 18:08:56</createdate>
<rma_number>81841648</rma_number>
<service_request>606205681</service_request>
<device>DRHMNCRRZ-D6601S1</device>
<title>6506 MOD 2 & 16 RESETTING</title>
</ItemAttributes>
</Item>
<Item>
<RMA>81841141</RMA>
<DetailPageURL>none</DetailPageURL>
<ItemAttributes>
<createdate>2007-06-15 13:13:46</createdate>
<rma_number>81841141</rma_number>
<service_request>606220305</service_request>
<device></device>
<title>MRBOMALDZ-UCD01S1 Faulty PS</title>
</ItemAttributes>
</Item>
</Items>

trbs
5 Jul 2007, 6:40 PM
& is not a valid xml character i believe.

xml is quite strict in these kind of things. please read the xml specs carefully if your building your own xml (output) parser or use one of the existing onces.

rule of thumb: never send any invalid xml document from your server/data source (aka if they could not be validated by an xml validator)

In case my memory serves me correctly; the '&' in the xml is an invalid literal because it is used in the declaration of special character like '&amp;'

if you want a literal text block in xml you should use a CDATA block:


<title><![CDATA[6506 MOD 2 & 16 RESETTING]]></title>


specs: http://www.w3.org/TR/REC-xml/
(maybe not the best link, but it gives some insight.)

mystix
6 Jul 2007, 12:48 AM
yes indeed. & (ampersand) is not a valid XML character. never was. never will be (fingers crossed :) )

it is one of 5 predefined entity references in XML (excerpt taken from W3Schools - XML CDATA (http://www.w3schools.com/xml/xml_cdata.asp)):

&lt; < less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark

Note: Only the characters "<" and "&" are strictly illegal in XML.
Apostrophes, quotation marks and greater than signs are legal, but it is a good habit to replace them.

[edit]
and here's an online XML parser (http://www.xml.com/pub/a/tools/ruwf/check.html) from O'Reilly that will show you what's wrong with your XML.

amini
3 Dec 2008, 7:43 PM
Thanks for posting the issue. Solved my problem :)