Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML parsing problem involving quotes
Message
De
21/12/2005 14:41:22
 
 
À
21/12/2005 11:10:35
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:
01079980
Vues:
18
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, '<', '&lt;')
	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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform