This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating XML from java

 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am wondering if there is a way to generate the xml from java
i mean that after creating an element using this code

system.out.println(element);
i get <element>text of element</element>

or do i have to type them each time like
system.out.println("<"+element.getTag +">"+element.getTextNode()+"</");
etc,,

thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a Document object in memory you can use a Transformer to output it as a stream to a file or buffer in memory.
See these classes:
 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, that was very helpful

[ August 02, 2006: Message edited by: Maha Hassan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic