Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Parsing CDATA

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    19
    Thanks
    2
    Thanked 1 Time in 1 Post

    Question Parsing ---- CDATA

    Hi,

    Is there any way to extract the content in CDATA sections...?
    as they cannot be parsed..

    for example

    <message><![CDATA[hello world];]></message>

    in the above tag i want to extrat tag value "hello world"
    which cannot be done by parsing the XML and using --- .getnodeValue()

    ---------------

    thanks
    Sai
    Last edited by Sai; April 8th, 2010 at 12:20 AM.


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: Parsing CDATA

    apply some regex to the line to pull it out.
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  3. #3
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Parsing CDATA

    You should be able to parse this as ordinary XML as the CDATA is just a way of saying that the data is unparsed.

    Your XML however appears to be invalid.

    <message><![CDATA[hello world]]></message>

    There was a semicolon between the brackets on the end of the CDATA tag.

    // Json

  4. #4
    Junior Member
    Join Date
    Mar 2010
    Posts
    19
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Parsing CDATA

    hehe that's not the full XML i did some mistake while copying it here ..ok ny way it worked when i parsed with a normal parser.. .. thanks for the support

Similar Threads

  1. java xml-rpc response parsing to xml
    By kievari in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: November 19th, 2009, 01:36 PM
  2. Parsing By Prediction Algorithm(?)
    By benjamin in forum Collections and Generics
    Replies: 5
    Last Post: September 30th, 2009, 03:21 PM
  3. Input file parsing to insert into DB
    By IDForums in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 30th, 2009, 02:29 AM
  4. Printing xml to the console from .wmdb without printing junks
    By John in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: April 24th, 2009, 03:44 AM
  5. [SOLVED] Parsing ID3 tags from mp3
    By John in forum Java Theory & Questions
    Replies: 14
    Last Post: April 16th, 2009, 01:36 PM