Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Junk characters illegal for XML
Message
 
À
08/04/2014 09:54:58
Denis Filer
University of Oxford
Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01598264
Message ID:
01598278
Vues:
65
J'aime (2)
>Does anyone know a good way to remove illegal characters (i.e. disliked by XML) from text strings being exported to XML files. Some of our old databases, even some new, have erroneous characters (special symbols, right angles, odd smiley faces, and the like) which throw XML. We check of course for for XML tags < and >, & and also I pass strings through a whole series of STRTRAN() commands trying to trap and remove these - but all to often, another weird character crops up and throws the XML file. We are not using CDATA. Any hints here greatly appreciated. Denis
** This is a complete list of good XML characters in the windows 1252 character set
LOCAL lcGoodChars,lcBadChars
lcGoodChars=[]
lcGoodChars=lcGoodChars+CHR(9)	&& tab
lcGoodChars=lcGoodChars+CHR(10)	&& 
lcGoodChars=lcGoodChars+CHR(13)	&& enter
lcGoodChars=lcGoodChars+CHR(32)	 && space
FOR lnGoodChars=33 TO 128
	lcGoodChars=lcGoodChars+CHR(lnGoodChars)
ENDFOR
FOR lnGoodChars=130 TO 140
	lcGoodChars=lcGoodChars+CHR(lnGoodChars)
ENDFOR
lcGoodChars=lcGoodChars+CHR(142)
FOR lnGoodChars=145 TO 156
	lcGoodChars=lcGoodChars+CHR(lnGoodChars)
ENDFOR
FOR lnGoodChars=158 TO 255
	lcGoodChars=lcGoodChars+CHR(lnGoodChars)
ENDFOR


** check the lcValue for bad chars
lcBadChars=CHRTRAN(lcValue,lcGoodChars,'')
IF !EMPTY(lcBadChars)
	lcValue=CHRTRAN(lcValue,lcBadChars,'')
ENDIF
Brandon Harker
Sebae Data Solutions
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform