hi all i want to create an xml file from an array
i've been googling but can't find the right one
the closest one that i get is in http://www.higherpass.com/java/Tutorials/Building-Xml-With-Java-And-Dom/
but it doesn't create an xml file like i wanted to
i want to print and create it like c:\xml file\data.xml

can anybody show me the code or any link that actually print like how i wanted?
any help would be appreciated, thanx :)

Recommended Answers

All 6 Replies

hat actually print like how i wanted?

Can you explain "how I wanted"?

The site at your link has code to generate Strings of XML and print them on the screen.
Have you tried replacing the 'print to screen' method calls with classes and methods that will write the Strings to a file?

sorry if my explanation not clear
it's just a simple xml like

<?xml version="1.0"?>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<item>
    <id></id>
    <name></name>
</item>
<item>
    etc
</item>
</data>

and yes what i need is how to write string into file that is xml :)
any references while i keep looking and trying?

how to write string into file

There are plenty of examples of how to do that.
Try Searching for PrintWriter for sample codes that write Strings to files.

thanx a lot NormR1 i've got the solution
may i ask again?
which one is faster for writing strings to file
is it using bufferedWriter or PrintWriter?
or there is another method coz i only found this two solution

i want to parse a large dataset which i process from java into php for presentation
which one is faster to read
is it from text, xml, or database?

sorry if i was asking too much and out of topic because i'm a newbie
i've only tried it on a small dataset and can't see the differences...

which one is faster

Don't worry about it yet.
If your really interested write some test programs and time them using the System.currentTimeMillis() method at start and end of job.

thanx you are a great help NormR1
i wonder when are u sleeping coz your answer is really fast :)
GBU

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.