Simple Java DOM XML Tutorial

Discussion in 'Java' started by Gene Davis, Apr 6, 2004.

  1. Gene Davis

    Gene Davis Guest

    Gene Davis, Apr 6, 2004
    #1
    1. Advertising

  2. Gene Davis

    Mohun Biswas Guest

    Gene Davis wrote:
    > I've added a tutorial/example to my site that shows
    > the creation of a simple DOM XML tree and then
    > spitting it out as a String.
    >
    > Hopefully this is useful to someone :)


    I certainly found it useful - thanks very much! I've been generating a
    little XML document using a StringBuffer for a while now and converting
    it to DOM has been on my to-do list. Your tutorial made it look so easy
    I pushed it to the top of the stack and just did it.

    One thing, though - it doesn't cover how to add a CDATA section and I
    can't see the answer immediately from the JavaDocs. Any chance you could
    add an example of that?

    Thanks a lot,
    MB
     
    Mohun Biswas, Apr 6, 2004
    #2
    1. Advertising

  3. Gene Davis

    Mohun Biswas Guest

    Mohun Biswas wrote:
    > One thing, though - it doesn't cover how to add a CDATA section and I
    > can't see the answer immediately from the JavaDocs. Any chance you could
    > add an example of that?


    Never mind, got it:

    CDATASection cds = doc.createCDATASection(<string>);
    root.appendChild(cds);
     
    Mohun Biswas, Apr 6, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    568
  2. Replies:
    3
    Views:
    548
    Stefan Behnel
    Aug 3, 2007
  3. Alan
    Replies:
    6
    Views:
    1,638
  4. Begin Learning Java
    Replies:
    5
    Views:
    621
    Arne Vajhøj
    Mar 17, 2010
  5. Lew
    Replies:
    0
    Views:
    409
Loading...

Share This Page