Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parsing Error - Invalid Token Due to &
Message
From
05/05/2004 15:20:33
 
 
To
05/05/2004 15:02:31
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00901300
Message ID:
00901315
Views:
34
Hi Mike,

I'm trying your function and what is strange is that about every 3rd time I compile my project it errors during compile on it:
lcReturn = STRTRAN(lcReturn, '<', '
Error in line 919: Command contains unrecognized phrase/keyword.
It only occurs about every other to every 3rd time during compiling, any idea why?

To ensure I cut and paste it correctly, here is the code again:
*--Courtesy Mike Hellend UT Thread 901300
FUNCTION XmlEncode
LPARAMETERS teExpression
LOCAL lcReturn

lcReturn = TRAN(teExpression)

IF VARTYPE(teExpression) = 'C'
	lcReturn = ALLTRIM(lcReturn)
	lcReturn = STRTRAN(lcReturn, '&', '&amp;')
	lcReturn = STRTRAN(lcReturn, '<', '&&#108;t;')
	lcReturn = STRTRAN(lcReturn, '>', '&gt;')
	lcReturn = STRTRAN(lcReturn, '"', '&quot;')
	lcReturn = STRTRAN(lcReturn, "'", '&apos;')
ENDIF 

RETURN lcReturn
>>That line is the value line below and when I remove the & it runs fine. How can I include the & in a value? I need to in some cases...
>
>The & is a reserved symbol, but can be created literally like so:
>
>
&
>
>Here's a function I have in my library that I use to XMLify everything that goes into an XML document:
>
>
* Xml Encode
>* This program gets stuff ready for XML. It'll take anything. Its tough.
>LPARAMETERS teExpression
>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
>
>RETURN lcReturn
>
>From your last couple posts looks like you're doing a little string manipulation, eh? Fun stuff. XML'll give you a headache at first but once you learn its ins and outs the love affair will never end.
.·*´¨)
.·`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"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform