In this tutorial, we will implement append() method of CDATA class. The
CDATA class is available
in org.jdom package. The append(
java.lang.String string) method will append character data
with
in this CDATA node.
In this example, we can create a CDATA node with the help CDATA class. The CDATA(java.lang.String string) constructor of CDATA class crates a CDATA new node with a string.
The setContent(Content content ) method of Element class is used to set the content at element.
Code:Book.xml
<?xml version="1.0" encoding="UTF-8"?>
|
AppendCdata .java
package roseindia;
|
|
<?xml version="1.0" encoding="UTF-8"?>
<BookCatalog> <book name="java"> <![CDATA[<Detail>java is a programming book.</Detail>.It support oops concept.]]></book> <book name="c" /> </BookCatalog> Charater data : <Detail>java is a programming book.</Detail>.It support oops concept. |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.