Solved

Generating XML with Classic ASP Ampersand CDATA Problem

Posted on 2008-10-14
4
780 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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, …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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)

762 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