Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML parsing problem involving quotes
Message
De
21/12/2005 16:26:18
 
 
À
21/12/2005 16:05:00
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01079885
Message ID:
01080030
Vues:
15
Mike Helland provided it originally I think. Here is the message:

Oops - this one was fixed:

Re: Parsing Error - Invalid Token Due to & Thread #901300 Message #901315


>Hi Tracy,
>
>I don't have control of the XML creation. It is XML that is being handed to me and I'm trying to load it into an XMLAdapter object.
>
>I'm aware of those special characters in XML, however, I don't understand your "Encode" code. I guess IE is somehow transforming your &, < etc. Wait a second...I just previewed this response and yes, some of the special characters are being "kidnapped":) Oh well...
>
>
>Mike
>
>>In xml use the entity reference for the apostrophe when the xml is created. Keep in mind the 5 predefined entity references. I have a utility for this from the generosity of other UTers:
>>
>>*--Encode
>>LOCAL lcReturn
>>lcReturn = TRAN(teExpression)
>>IF VARTYPE(teExpression) = 'C'
>>	lcReturn = ALLTRIM(lcReturn)
>>	lcReturn = STRTRAN(lcReturn, '&', '&')
>>	lcReturn = STRTRAN(lcReturn, '<', '<')
>>	lcReturn = STRTRAN(lcReturn, '>', '>')
>>	lcReturn = STRTRAN(lcReturn, '"', '"')
>>	lcReturn = STRTRAN(lcReturn, "'", '&apos;')
>>ENDIF
>>
>>*--Decode:
>>FUNCTION XMLDeCode
>>LPARAMETERS cTXT
>>LOCAL i,ch
>>FOR i=1 TO 255
>>  ch=ALLTRIM(STR(i))
>>  cTXT=STRTRAN(cTXT,"&#"+ch+";",CHR(i))
>>ENDFOR
>>RETURN cTXT
>>
>>
>>>Hi All,
>>>
>>>I have a string of XML that I'd like to load into an XMLAdapter. I can do this most of the time by calling the latter's LoadXML() method and passing in the XML string. Occasionally, the method causes an error because the XML string contains single quote delimited values that can contain an apostrophe. This throws off the balance of quotes. Here's an example snippet:
>>>
>>>
>>><rs:data>
>>><z:row LandStreetNum='1000' LandStreetName='Richard's St'... />
>>></rs:data>
>>>
>>>
>>>Note how Richard's St messes up the quotes.
>>>
>>>Is there any way to tell the XMLAdapter to substitute double quote "delimiters" for single quotes when it tries to LoadXML()? Of course it has to ignore the apostrophe too :)
>>>
>>>TIA
>>>
>>>Mike
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform