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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Remove [[CDATA] and ]] from an xml file" Watch "Remove [[CDATA] and ]] from an xml file" New topic
Author

Remove [[CDATA] and ]] from an xml file

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
Hi!

I have an xml file with a tag like this:

<main>
<![CDATA[
<div class="hugin">
<div class="hugin">KONCERNCHEFENS KOMMENTARER</div>
<div class="hugin"> </div>
<div class="hugin">"Vi har sett den st�rsta �kningen i antalet mobiltelefonanv�ndare n�gonsin. Under 2004 tillkom 300 miljoner nya anv�ndare och nu har 27 procent av v�rldens befolkning tillg�ng till mobiltelefoni", s�ger Carl-Henric Svanberg, VD och koncernchef f�r Ericsson. "F�r oss som har en vision om en v�rld d�r alla kan kommunicera med varandra - n�r som helst och var som helst - �r detta en sp�nnande utveckling.</div>
]]>
</main>

I want to write to an xml document something like this:

<main>
<div class="hugin">
<div class="hugin">KONCERNCHEFENS KOMMENTARER</div>
<div class="hugin"> </div>
<div class="hugin">"Vi har sett den st�rsta �kningen i antalet mobiltelefonanv�ndare n�gonsin. Under 2004 tillkom 300 miljoner nya anv�ndare och nu har 27 procent av v�rldens befolkning tillg�ng till mobiltelefoni", s�ger Carl-Henric Svanberg, VD och koncernchef f�r Ericsson. "F�r oss som har en vision om en v�rld d�r alla kan kommunicera med varandra - n�r som helst och var som helst - �r detta en sp�nnande utveckling.</div>
</main>

Any ideas?? Please help.


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
ummm...before I dive into suggesting something here -
There's a reason why CDATA is used (or abused?). Are you really sure you want to do this ? Does this CDATA always have XML-like content?

- m


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5
I feel your pain I have a client whose XML documents have huge chunks of CDATA that is also formatted as XML. If you don't need to actually manipulate that content as XML you are lucky.
The simplest thing might be to just tackle it as a text filter problem and never go through XML at all - just line by line take input and write output.
Look for the start of CDATA or the end of CDATA in a line and just cut it out of the line.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Remove [[CDATA] and ]] from an xml file
 
Similar Threads
Tomcat madness!
Writing a sum to a file
Problem when submit a form with HTTPUnit
"cannot find symbol"
need some help....