File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB: Creating a message with a CDATA section

 
Rick Portugal
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic