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

x
?
Solved

xml contails & and single quotes

Posted on 2003-11-09
8
Medium Priority
?
299 Views
Last Modified: 2013-11-19
Hi ,
I am using jaxp to create my xml. I am fetching the values from database and mydata has & and ' ' . How can i allow special characters?
Do i have to specify something in my DTD for ignoring this kind of data.
Please help.
Mehak
0
Comment
Question by:mehaklala
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
purpleblob earned 1000 total points
ID: 9711279
When there's a chance you'll output characters which have special meaning then enclose the output data in a <!CDATA[ ] ]> block then anything within this block is ingored in terms of parsing the XML
0
 
LVL 7

Expert Comment

by:wsteegmans
ID: 9714631
You can indeed use the CDDATA block, but that's not such a nice solution ...

In XML, there are indeed some special characters you can't use ...

But, just like HTML, XHTML and XML provides built-in entities for representing markup characters inside of markup without disrupting parsing:

So, do a replace of all these characters ...

[&amp;] => Ampersand (&)
[&lt;] => Less Than (<)
[&gt;] => Greater Than (>)
[&apos;] => Apostrophe (')
[&quot;] => Quote (")
0
 
LVL 6

Expert Comment

by:purpleblob
ID: 9714934
I'm intrigued - why is CDATA not such a nice solution ?

If you're reading data out of a database you'd have to convert the "special characters" to the &X; equivalent's each time you create the XML output or store the data within the database in this format. Whilst enclosing the output from the db into a CDATA block requires no processing.
0
 
LVL 7

Expert Comment

by:wsteegmans
ID: 9722804
Let's say it's more personnal, but I prefer to minimize the use of CDATA.

But, you're absolutely right when building big XML-files with data from a DB, you can indeed better use CDATA.
0
 
LVL 7

Expert Comment

by:wsteegmans
ID: 9791664
mehaklala,

Did these comments solved your problem?
Please, give us some additional info/input, if required.

thx!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 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