Solved

Generating XML with Classic ASP Ampersand CDATA Problem

Posted on 2008-10-14
4
775 Views
Last Modified: 2013-11-18
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
Comment
Question by:miditainment
  • 2
  • 2
4 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 22718354
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
 

Author Comment

by:miditainment
ID: 22718409
Perfect!  Gracias!
0
 

Author Closing Comment

by:miditainment
ID: 31506162
Thank you!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22718467
:)  Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question