Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing & into XML file

 
manoj kumar jena
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
i am writing data from database into an XML.Then, i am retrieving those data from XML to view on jsp.
but when i am writing the data into XML file i am getting an exception(related to XML format) because my data contains '&' symbol (for example javaranc & rocks).it says "not well-formed".

so how to write these kind of data(which contains special characters like &) into XML?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Characters that have special meaning in XML have to be "escaped" to pass XML parsers.

You might as well get familiar with the authoritative XML specification at W3C. Look for the section titled:

2.4 Character Data and Markup

Bill
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the lazy person's way to escape them is to put every text node into a CDATA section. (That's covered in the XML spec.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic