• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ArrayList to XML - usage of CDATA

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an ArrayList of ArrayLists, and want to write the data into a XML.

I wrote an obvious loop that attaches tags and prints out the XML contnet.

The problem is if a particular value has special characters, I know I have to use CDATA but then how do I do that selectively?

If all values are kept in CDATA (without checking whether or not they have chracters that need to be enclosed in CDATA) then is it a good practice OR should I check and add CDATA (which will be a costly if condition inside the loop) OR any other option exists?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to do it selectively. If you want to use CDATA for every single text node there is no reason why you shouldn't do that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic