Solved

xml contails & and single quotes

Posted on 2003-11-09
8
291 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
[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
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Progress
Suggested Courses

630 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