Re: create a XML file



On Fri, 29 Apr 2005, Nik wrote:

> how can I create a XML file with java which looks like this when opened:
>
> <archive name="archive1">
> <file name="xx">
> <size>100</size>
> <ext>jpg</ext>
> </file>
> </archive>

One possible way:

- Create a file using java.io.File
- Create an output stream using java.io.FileWriter
- Wrap the output stream with java.io.PrintWriter
- Use the println() method of PrintWriter to output the text
- Close the output stream

If you are having trouble figuring out how to do this, post your code and
I'm sure lots of people will help you out.

--
Send e-mail to: darrell dot grainger at utoronto dot ca

.



Relevant Pages

  • Re: Trouble getting XML stream from ASP to work
    ... modifying the code. ... browser, but viewing the source I see that the XML is indeed returned. ... If I used the output stream variable, ... download/save an XML file. ...
    (microsoft.public.sqlserver.xml)
  • Re: Sending object over network WITHOUT using serializable interface
    ... Why don't you just write the bytes into the output stream directly? ... > The C structure is about 15 or so shorts and ints. ... > C to Java and need to send the same data format from a java program. ... > I've defined a Java Class consisting of the ints and shorts in the ...
    (comp.lang.java.programmer)
  • Re: Unsigned byte values
    ... The C++ program requires a UBYTE, ... Java doesn't have unsigned bytes - only signed bytes ... you can keep your values of 0 to 255 in an int. ... just before you pass the byte to your output stream. ...
    (comp.lang.java)
  • Re: Ruby Socket to Java Socket
    ... "ordinary" output stream to the outside world and translate to ... The Java server is reading a Marshalled Java object, ... If you are sending very simple Java Objects you could format it in Ruby ... Try using JRuby instead and serialize the Java object in Java. ...
    (comp.lang.ruby)
  • Re: Writing to others Process STDIN
    ... > line windows where in each of this windows runs a Java Process. ... I may be missing something but I don't see where the Win32 API figures into ... The problem is that you want to save the output stream of the Java ...
    (microsoft.public.vc.language)