File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes XML parsing and value storage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML parsing and value storage " Watch "XML parsing and value storage " New topic
Author

XML parsing and value storage

Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243
Hi,
I need to parse XML file using DOM parser and store it and need to do some calculations and again have put those values in XML. can any help me reg this.


SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

As per your requirement, please check JAXB (Java API for XML Binding) which exactly fits in.

In precise, JAXB as the term indicates, helps you to get the XML contents in terms of equivalent Java Objects and also to represent the Java objects back into XML representation.

When you have the Java object equivalence, you are free to do any changes to the content you want! Then you can convert back them into XML using the same JAXB.

The processes are called Marshalling and UnMarshalling.

This tutorial is an excellent one which gives you enough information right from the basics.

You can also look into the online documentation for the same.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Parsing to the DOM is a lot simpler than parsing with JAXB. Note the difference: Parsing described in the standard APIs gives you the W3C DOM, a graph of standardized generic objects that represent XML bits and pieces. Parsing with JAXB gives you a graph of non-standard objects that have classes and field names that match the tags in the XML. I would personally walk a long ways to avoid JAXB on most days, but sometimes it pays off.

Either way, you can modify the graph of objects and generate a new XML string. Now the ease of use goes the other way ... the DOM is a pain to work with, while the custom Java objects you get from JAXB might more feel like normal Java work.

There is an XML forum here at the ranch. Maybe scroll down there and ask for examples. Let us know how you make out!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Thanks for the inputs Stam.

As you said, i have suggested JAXB for a simpler efforts to get back the XML back after modifying the contents.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML parsing and value storage
 
Similar Threads
What is AJAX?
why DD is in XML?
XML coding standards
Removing XML declaration in XML file
reading xml file dynamically