Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 118,882 Java Programmers for FREE! Ask your question and get quick answers from experts. There are 1,978 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



JAVA and XML

 
Reply to this topicStart new topic

JAVA and XML

fsloke
post 3 Jul, 2008 - 03:49 AM
Post #1


D.I.C Head

**
Joined: 19 Dec, 2007
Posts: 235



Thanked 1 times
My Contributions


Just need some idea from you all...

May I know is there has any standard class that can convert message to xml sheet format?

Example
Just assume the library is XXX...

Raw Data:
=========
String name= "fsloke";
String country="Malaysia";

When I put into the library:
==================

XXX a= new XXX("C:\output.xml");
a.addRoot("USERS");
a.add("name",name);
a.add("country", country);
a.close();

The result is....
===================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE USERS SYSTEM "users.dtd">
<USERS>
<name>fsloke</name>
<country>Malaysia</country>
</USERS>

Thank you....

User is offlineProfile CardPM

Go to the top of the page


Programmist
post 3 Jul, 2008 - 07:58 AM
Post #2


Four-letter word

Group Icon
Joined: 2 Jan, 2006
Posts: 1,175



Thanked 6 times

Dream Kudos: 100
My Contributions


I'm not quite sure exactly what you are tyring to do. If you are trying to convert an object to XML, then XStream is a great library for that - and very easy to use. If, however, you want to convert a JDOM Document to XML, use JDOM's XMLOutputter class. Here's an example.
User is offlineProfile CardPM

Go to the top of the page

fsloke
post 3 Jul, 2008 - 07:35 PM
Post #3


D.I.C Head

**
Joined: 19 Dec, 2007
Posts: 235



Thanked 1 times
My Contributions


Thank you for Programmist.

My xml and dtd is in the same folder and in the separate file.
Just assume a.xml and a.dtd

May I need to add what <....> in the xml so the dtd will check the syntax of the xml..

Thank you
User is offlineProfile CardPM

Go to the top of the page

Programmist
post 7 Jul, 2008 - 03:00 AM
Post #4


Four-letter word

Group Icon
Joined: 2 Jan, 2006
Posts: 1,175



Thanked 6 times

Dream Kudos: 100
My Contributions


http://www.w3schools.com/DTD/default.asp
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 02:50AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month