Simple Java DOM XML Tutorial

M

Mohun Biswas

Gene said:
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
 
M

Mohun Biswas

Mohun said:
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);
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top