Solved

Generating XML with Classic ASP Ampersand CDATA Problem

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

738 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