aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXB: Creating a message with a CDATA section Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB: Creating a message with a CDATA section" Watch "JAXB: Creating a message with a CDATA section" New topic
Author

JAXB: Creating a message with a CDATA section

Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
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.


IBM 286, SCJP, SCWCD, EIEIO
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
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

Joined: Mar 22, 2000
Posts: 12682
    
    5
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


Java Resources at www.wbrogden.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAXB: Creating a message with a CDATA section
 
Similar Threads
JAXB DOCTYPE
XML Schemas and CDATA
Parsing special charaters
Webservices with Axis 1.3
JAXB in eclipse