• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beginner Java and XML questions

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm an absolute beginner with Java and XML. I know XML fairly well. I would really appreciate it if someone could point me to a tutorial or a book that explains how to read and generate XML files using Java.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not Sun's tutorial on XML and Java?

You will never be allowed to continue on the Ranch with an obviously fake name. Go fix it.

Bill
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the big deal with the names here?

Besides, I need something even simpler and easier, if there is any...
[ June 29, 2006: Message edited by: Edward Morris ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Edward Morris:
Whats the big deal with the names here?



See here and here for some background. We do take this rule (as well as the "Be Nice" rule) quite seriously.

Now, as far as your questions go: as you know, XML is just plain text. The very simplest way to create it is like this:

System.out.println("<?xml version='1.0'?>");
System.out.println("<body></body>");

Can't get much easier than that!

Now, for more helpful APIs, the tutorial mentioned above is going to be the best source. I can help you focus by pointing out the parts you really want to see. This document tells you how to build a DOM (document object model) using API calls, and then this page tells you how to turn a DOM into an XML file on disk.

Finally, here's the documentation page for the JDOM project; JDOM is similar to the standard DOM API, but simpler (and non-standard.) You pays your nickle and you makes your choice.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Edward Morris:
Besides, I need something even simpler and easier, if there is any�



I don't know about simpler � but at some point of time you may want to have a look at Elliotte Rusty Harold's Processing XML with Java.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For ultra-simple, the O'Reilly XML Pocket Reference at 175 pages, is about the simplest you can get.
Harold's book is the best all-around reference I know of here is an online version. It is HUGE because the subject is huge.
Bill
 
Edward Morris
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot guys, thats some good help I needed. I'm surprised JR doesn't have its own tut for this topic. Well to give you guys the big picture, I am working on this project

www.cs.bsu.edu/homepages/gnet/jedit.htm

Its a simple graph drawing s/w with some good graphs and algorithms.

Two things I wanna do with this are :

1. Incorporate XML output for the graphs and later graphml output.

2. Make this app runnable from the web, something like this

http://www.yworks.com/en/products_yed_about.htm


I'm a newbie with both of the above and I could really use some good and fast teaching help, and of course, I would really really appreciate it.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this was my problem I probably would start by thinking about how to represent the data points both as Java objects and as XML Elements.

In some projects where a Java object represents some sort of unit of data, I have given the class a toXML( Writer out ) method and a constructor that takes the corresponding XML Element.

There are lots and lots of toolkits for transforming XML to objects and back if you don't want to tackle the problem that way. Browse some of the recent discussions here for examples or do a search for "java xml serialization".

Bill
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic