posted 10 years ago
Thanks Gregg. I took a look at JSON and looks interesting.
If you feel passing the data over http on xml (kind of) structure, is there any reason behind it? Isnt the DOM / SAX parsers on java good enough to parse these?
Also on the reverse side, the server passing XML-RPC data (say JSON itelf), wouldnt it be a cleaner approach?
I dont think you even have to parse it, the browser does the parsing.
That's not entirely true. You still have to traverse it. Let's assume an XML structure like this....
To get the contents of the first employee tag you would need to do something like
That might not seem too bad but this is a simple bit of XML. Imagine something more complex and needing to loop over children of children of children to get elements you need. If you consider the same code as JSON, to get the first employee you would do something like...
Bharath, yes, there are some excellent ways to parse XML on the server using Java. But consider this. You have an object to populate with the data you get back from the server. This data is going to be in a Map (HttpServletRequest). It's already structured for you. Simply pull the values out of the map. Why the extra step of parsing XML?
With regards to XML-RPC, like I said, I avoid sending XML if at all possible. Sometime it does make more sense (SOAP, WSDL, etc). You asked a pretty generic question with no real context and that is what I was giving an answer to. If you would like to get into more specifics about your problem domain then I'm sure we could provide some pinpointed advice to that situation.
My pie came with a little toothpic holding up this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!