Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
English
Parsing Error - Invalid Token Due to &
Message
General information
Fórum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
ID da thread:
00901300
ID da mensagem:
00901368
Views:
27
This message has been marked as a message which has helped to the initial question of the thread.
Probably overkill, but I use this for XML Strings.
This function transform everything that is not A-Z, 0-9 or a-z to "&" tag

XMLtext
LPARAMETERS cTxt
LOCAL cNewTxt,i,nChar
cNewTxt=""
FOR i=1 TO LEN(cTxt)
  nChar=ASC(SUBSTR(cTxt,i,1))
  IF BETWEEN(nChar,33,47) OR BETWEEN(nChar,58,64) OR BETWEEN(nChar,123,255)
    cNewTxt=cNewtxt+[&#]+ALLTRIM(STR(nChar))+[;]
  ELSE
    cNewTxt=cNewtxt+SUBSTR(cTxt,i,1)
  ENDIF 
ENDFOR 
RETURN cNewTxt
And UnXMLText
LPARAMETERS cTXT
LOCAL i,ch
FOR i=1 TO 255
  ch=ALLTRIM(STR(i))
  cTXT=STRTRAN(cTXT,"&#"+ch+";",CHR(i))
ENDFOR 
RETURN cTXT
HTH :)

>Hi Mike
>
>I totally forgot about the illegal charcters. After your post, I dug out the book and found them. It only shows the below five. Are they anymore?
>
>Shees, forget the listing. I can't seem to get them posted without the UT parser changing them! Are there any more?
>
>less than
>greater than
>apostrophe
>quotation mark
>ampersand
>
>TIA,
>Tracy
>
>>>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:
>>
>>Hehe, the UT parser messed something up (I think it does a quick parse, and then an mhHTMLCode on the PRE sections, and it should avoid the quick parse on PRE sections, but thats just a guess).
>>
>>The function, which I call xe.prg (because I use the function alot I prefer xe(string)) should use this line for the less than sign:
>>
>>lcReturn = STRTRAN(lcReturn, '<', '<')
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Previous
Next
Responder
Mapa
View

Click here to load this message in the networking platform