Chirstofer,
Did you try the example in the javadoc? http://xmlbeans.apache.org/docs/2.4.0/reference/org/apache/xmlbeans/XmlOptions.html#setUseCDataBookmarks() Cezar _____ From: Christopher Cheng [mailto:christopher.sw.ch...@gmail.com] Sent: Tuesday, June 01, 2010 4:57 AM To: user@xmlbeans.apache.org Subject: Re: Cannot get CDATA to work After digging into the codes, I found out that StaxUtils is responsible to decide whether it's 'CHARACTER' or 'CDATA'. The XMLStreamReader used is 'com.sun.xml.fastinfoset.stax.StAXDocumentParser'. It looks like that after XMLBeans passed the XMLDocument to StAXDocumentParser, at line 381 of StAXDocumentParser could not determine whether it is plain CHARACTER eventType of CDATA eventType. My quick fix is to add the followings to "copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment)" of StaxUtils. It's ugly, I know, so hope somebody could fix it. case XMLStreamConstants.CHARACTERS: if (reader.getText().startsWith("<![CDATA[") && reader.getText().endsWith("]]>")) { String text = reader.getText(); writer.writeCData(text.substring("<![CDATA[".length(), text.length() - "]]>".length())); } else { writer.writeCharacters(reader.getText()); } break; On Mon, May 31, 2010 at 11:40 PM, Christopher Cheng <HYPERLINK "mailto:christopher.sw.ch...@gmail.com"christopher.sw.ch...@gmail.com> wrote: I went thru a few posts in this list, but still no luck to get CATA to work. I am using xmlbeans version 2.4. What's wrong with the followings? node.setKey("ABCDEFG"); XmlCursor c = node.xgetKey().newCursor(); c.toFirstContentToken(); c.setBookmark(CDataBookmark.CDATA_BOOKMARK); System.out.println(node);