Generating XML with Classic ASP Ampersand CDATA Problem

I'm generating some XML via Classic ASP - and having problems with data that has special characters like Ampersands.  Now - I've got most of it resolved...but I'm missing a key to the syntax for one part of it.

Most of the XML is formed like this...

<field><![CDATA[<%=myauthor%>]]></field>

which works perfectly.  However - there's one part of the XML that is formed like this...

<mytext text="blah & blah & blah" /> - which is screwing it up.

I thought about trying:

<mytext text=<!CDATA["blah & blah & blah"]]> /> - but that didn't work.

How do I get around this problem?
miditainmentAsked:
Who is Participating?
 
b0lsc0ttConnect With a Mentor IT ManagerCommented:
miditainment,

You need to html encode the ampersands and other reserved html characters.  You can use Server.HTMLEncode to do this if you have the data in a variable or manually do it.  To manually encode the & character you use &amp; .

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
miditainmentAuthor Commented:
Perfect!  Gracias!
0
 
miditainmentAuthor Commented:
Thank you!
0
 
b0lsc0ttIT ManagerCommented:
:)  Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0
All Courses

From novice to tech pro — start learning today.