Solved

xml contails & and single quotes

Posted on 2003-11-09
8
274 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
8 Comments
 
LVL 6

Accepted Solution

by:
purpleblob earned 250 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

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

Title # Comments Views Activity
mergeTwo  challenge 13 72
noX challenge 17 76
array11 challenge 16 51
creating threads in delphi 1 54
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

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

20 Experts available now in Live!

Get 1:1 Help Now