Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parsing xml

 
angelin precilla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any one help me how to parse xml using struts.
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ UD: Removed hijack. Please start a new topic for unrelated questions. ]
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to a more suitable forum, since the question has nothing to do with Struts.
 
Prabhakar Reddy Bokka
Ranch Hand
Posts: 197
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic