Solved

Generating XML with Classic ASP Ampersand CDATA Problem

Posted on 2008-10-14
4
767 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now