aspose file tools*
The moose likes XML and Related Technologies and the fly likes CDATA and jdom Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "CDATA and jdom" Watch "CDATA and jdom" New topic
Author

CDATA and jdom

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
Hi,
How to read CDATA from xml using jdom parser.

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18666
    
    8

It's just a text node, isn't it? What have you tried so far?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 535
    
    3
>How to read CDATA from xml using jdom parser.
One of the typical occurrence of getting to a content List through .getContent().iterator(), and then use .next() to arrive at an object (o) of type typically uncertain. You then have to test the type of the object (o) through a cascade of if... else if...

The CDATA object uses getValue() above, or for that matter it can use getText(), getTextTrim() etc... all inherited from Text class as CDATA subclass Text. The casting step of o to CDATA is important.

[note: edited a typo.]
 
 
subject: CDATA and jdom