Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Issue while Converting JSON to XML

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to convert json data to XML, which it is received from third party server i think it is arbitutuary JSON

My java codings is like this


output
====
Note:Converted XML result well shown in console but not in browser it show below error in eclipse ide browser



I attach here the json response from server .
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"<Postgraduate Certificate>" is not a valid XML element tag.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya,but how can rid this? my server release json it is not in my control what can i do,is any other way to achieve this using java coding?
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the JSON. (And I still suspect that converting JSON to XML is not the right to do to begin with, the difficulties you're having just being another indication of that.)
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Post the JSON. (And I still suspect that converting JSON to XML is not the right to do to begin with, the difficulties you're having just being another indication of that.)



I mind your suggestion,but if i follow means i have to restructure my project and also it is time constraint, please help me out to get rid of this problem

JSON RESPONSE FROM SERVER

 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you will have to restructure something, so you might as well think about whether a different overall design might be better.

The JSON has keys with spaces in it ("Postgraduate Diploma", "Postgraduate Certificate", maybe others); assuming that's legal JSON, it seems that the JSON-to-XML converter does not handle that well. I can't blame it for that, it's unusual JSON. Maybe the converter has hooks so that you can substitute a better tag name for those, or you need to use a different converter.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Well, you will have to restructure something, so you might as well think about whether a different overall design might be better.

The JSON has keys with spaces in it ("Postgraduate Diploma", "Postgraduate Certificate", maybe others); assuming that's legal JSON, it seems that the JSON-to-XML converter does not handle that well. I can't blame it for that, it's unusual JSON. Maybe the converter has hooks so that you can substitute a better tag name for those, or you need to use a different converter.




Am a fresher ulf,no senior to guide me,i believe only forums,so guide me to use which converter to solve my issue,i try jsonserializer,org.json lib, but no use ,also paste my json to freeformatter.com to convert xml,so that site also can't able to convert it shows NCName character is illegal,
this site can convert my json to xml but i dont know what converter they use,please guide me ulf
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If "no use" to any of the other JSON-to-XML converters means that you have tried them all, and none works -which I'd consider highly unlikely, but not out of the realm of the possible, especially with such unusual JSON- then I don't think i can help any further. I've never had a use for any of those converters, so I'm unfamiliar with them. And I've no interest in acquainting myself with them, as converting JSON to XML is something rather unusual that I can't see the value of; but I've mentioned that before, so no point in going over that again.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:If "no use" to any of the other JSON-to-XML converters means that you have tried them all, and none works -which I'd consider highly unlikely, but not out of the realm of the possible, especially with such unusual JSON- then I don't think i can help any further. I've never had a use for any of those converters, so I'm unfamiliar with them. And I've no interest in acquainting myself with them, as converting JSON to XML is something rather unusual that I can't see the value of; but I've mentioned that before, so no point in going over that again.




Hai ulf,now i give up the idea to convert json to xml,my incoming json response from third party server,i would like to send as well as JSON in my prototype,i trust you,please help me and solve my queries,

what i did in XML response from third party server is: let assume an example this xml came from third party server

Using Xpath i create own xml file and change the structure like(simplify the xml this what i told frequently),i achieve this thing in all type of xml response am strucking json response,so only i try to convert json to xml,but it give hand to my problem...



How can i achieve this thing in JSON please guide me,i get json from third party server and make simplify as my own and send to phonegap client,please help me and save me
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic