• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JAXB: Creating a message with a CDATA section

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I use JAXB to create an XML message that contains a CDATA tag?
I want to create an XML message that looks like this:

<thisTag><![CDATA[
123 456
789 321 ]]></thisTag>

But I can't figure out how to get "CDATA" to appear in the message.
 
Rick Portugal
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to force the CDATA tag by prepending the string "<!CDATA[[" to the contents of my data. But JAXB translated it to "& l t ; !CDATA[[". Does anybody know how to tell JAXB not to convert "<" to "& l t ;"?
[ December 29, 2004: Message edited by: Rick Portugal ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The org.w3c.dom.Document class has a method:
createCDATASection( String contents )
I'm not sure where JAXB fits into this, but Java 1.4 includes that package as part of the normal library.
Bill
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic