The moose likes XML and Related Technologies and the fly likes create xml string from data Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "create xml string from data" Watch "create xml string from data" New topic
Author

create xml string from data

Agnese Maria
Greenhorn

Joined: Jul 06, 2001
Posts: 2
Hi there...
I have to create an xml string to be sent over a socket connection from some data coming from a database. I could hard code all the xml tags but is tedious and error prone...can anybody help me with this?
Thanks thanks thanks
SAFROLE M3
Greenhorn

Joined: Jun 28, 2001
Posts: 18
Create a template XML file as text that already has the tags defined, then simply read the file into a DOM and populate the DOM dynamically with the data from the database.
SAF
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5781
Your name 'SAFROLE M3' does not comply with the JavaRanch naming policy. Please spare a moment and re-register with a name that meets the requirements. .
Thanks!


Open Group Certified Master IT Architect.
Sun Certified Architect(SCEA).
Agnese Maria
Greenhorn

Joined: Jul 06, 2001
Posts: 2
Thanks Safrole...do you have code samples that do that?
SAFROLE M3
Greenhorn

Joined: Jun 28, 2001
Posts: 18
Sheriff,
I'm not changing my name because I highly doubt another individual will attempt to register with a name that conflicts with mine.
Agnese,
This is a simple task. First, define a text file that acts as a template for your application. This file should be a well-formed XML document that contains tags with no values, so self-terminating tags will do, such as </tagName>.
Now, read your text file using InputStream to get the document contents into a DOM object. Once you have a DOM, you can navigate through it using the DOM API and insert values into your DOM as you see fit.
SAF
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5781
SAF,
I am sorry I can't make an exception in your case. The rule has to be followed by all registered users.
 
 
subject: create xml string from data
 
Threads others viewed
How to read/modify XML data in String format. Urgent Plz
Use of StringBuffer
how to remove control characters from xml data
Use of StringBuffer to add data
Class For Appending Data
developer file tools