File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes parsing xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "parsing xml" Watch "parsing xml" New topic

parsing xml

angelin precilla
Ranch Hand

Joined: Sep 11, 2007
Posts: 33

Can any one help me how to parse xml using struts.
Anirvan Majumdar
Ranch Hand

Joined: Feb 22, 2005
Posts: 261
As far as I know, parsing an XML hasn't got anything to do with Struts as such. You get an XML => you parse it and create a bean object (or any other suitable object); that's entirely your call.
You might want to consider reading up on the StAX parser, the SAX parser, or the DOM parser.
There are plenty of other implementations as well, but I think these would suffice for now. Considering what each of these parsers have to offer, and what your requirements are, you should make a call.
Personally, I would recommend the StAX parser for its balance of ease of use vs. performance.
angelin precilla
Ranch Hand

Joined: Sep 11, 2007
Posts: 33
My code is

I am getting the values , but the value of document and root is null.
My console outputs the following

Why am i getting null values ?
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138
[ UD: Removed hijack. Please start a new topic for unrelated questions. ]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Moved to a more suitable forum, since the question has nothing to do with Struts.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 193

2008-03-13 16:05:36,328 INFO [STDOUT] xmldoc :[#document: null]
2008-03-13 16:05:36,328 INFO [STDOUT] Root :[DatabaseList: null]
2008-03-13 16:05:36,328 INFO [STDOUT] ***************************

The null displayed in the out put is related to some documentation in the xml.
The Objects are not null but some value in side them is null.

[#document: null] - Document Owner Name
[DatabaseList: null] - First Child Element.

If you provide proper comments <DOCTYPE>, etc.., in your xml, you may see the values in them.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: parsing xml
It's not a secret anymore!