Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 818
  • Last Modified:

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?
0
miditainment
Asked:
miditainment
  • 2
  • 2
1 Solution
 
b0lsc0ttCommented:
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
 
b0lsc0ttCommented:
:)  Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now