I guess I was a bit slow - but it finally came to me. Added the following:
 
CDATA stuff = DocumentHelper.createCDATA("element3 <b>excellent</b> text");
Element em3 = root.addElement("element3").add(stuff);
 
Works fine.
 
Regards,
 
Terry 
----- Original Message -----
Sent: Tuesday, June 04, 2002 3:35 PM
Subject: [dom4j-user] Adding CDATA

I'm creating a document, using logic like this:
 
Element root = document.addElement("root");
Element em1 = root.addElement("element1").addText("element1 text");
Element em2 = root.addElement("element2").addText("element2 text");
 
Now I want to add a third element, but it will be a mixture of text and tags, such as "element3 <b>excellent</b> text".  I believe this should be treated as CDATA rather than text, but I'm not sure how to add it and would appreciate a bit of advice on this.
 
Regards,
 
Terry
 

Reply via email to