Full Version: Recordset XML and the dreaded "&" and tick
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
akhound
I'm dumping a recordset out into XML and would like to know if anyone knows of a way to change the ampersands to &amp and the apostrophes to &apos as its building the XML. I am doing this in ASP not right in access.

Darren


Edited by: akhound on Wed Dec 5 15:38:07 EST 2007.
HiTechCoach
Darren

I would probably use the Replace() function to format the data before exporting.

CODE
Replace( Replace([field],"&","&amp") , "'","&apos")


See:
http://www.w3schools.com/vbscript/func_replace.asp

Iy you have more to do them use a function, something like:

CODE
FUNCTION PreSubmit(p_sTargetString)

   PreSubmit = REPLACE(p_sTargetString,”textarea”,”")

   PreSubmit = REPLACE(PreSubmit,"'","&apos")

   PreSubmit = REPLACE(PreSubmit,"&","&amp")

   PreSubmit = Trim(PreSubmit)

END FUNCTION


Edited by: HiTechCoach on Wed Dec 5 15:49:41 EST 2007.
Dragyn
I believe you can also use an escape() function to convert all bothersome characters to safe alternatives. (And use and unescape() to put it back)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.