aspose file tools*
The moose likes XML and Related Technologies and the fly likes use java to create XML Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "use java to create XML Files" Watch "use java to create XML Files" New topic
Author

use java to create XML Files

Dan Xu
Greenhorn

Joined: Nov 29, 2002
Posts: 15
i wanna take loads of text files,and output the well-formed XML Files.
what should i do?
could anyone give me some links about this,any tutorials would be fine.
thanks!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The safest choice from a wellformed-ness point of view would be to use the DOM API and JAXP for constructing the XML documents in-memory, and then serialize them into the text-based XML files you need as output.
Another option would be to write the XML output by hand using a java.io.FileWriter and a lot of write("<something>") statements. Easy (no need to learn the XML programming APIs), but unsafe (you're responsible for encoding special characters correctly, etc.).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Dan Xu
Greenhorn

Joined: Nov 29, 2002
Posts: 15
thanks.
and another problem i met at this moment is,how can i read in the .doc files using java.
i can read in text files now,but how about the .doc
because i have to take them in and then convert them to xml file as output.
[ April 21, 2004: Message edited by: Dan Xu ]
[ April 21, 2004: Message edited by: Dan Xu ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
A simple google search for "read doc files with java" found this site.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use java to create XML Files