954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

[ASK] how to create an xml file from array

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 :)

1x4n
Newbie Poster
11 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
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?

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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?

1x4n
Newbie Poster
11 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
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.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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...

1x4n
Newbie Poster
11 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
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.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

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

1x4n
Newbie Poster
11 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You