• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

jersey and xml

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

i wanted to return a webpage as application/xml document.
below is my code. the returned value appears like a string in browser. However when i view the source, it is in xml.


java code



returnResult2() simply return a string. and the string is below:



this is what appear in the webpage.



this is what appears in the source code.




can someone advice me? i want to return the xml like a xml document (with indentation). instead of just a one liner string.


 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web page looks like that because the browser only obeys HTML tags and doesn' t know what to do with yours.

An XML document as a single line is perfectly valid and should be understood by any XML parser.

Bill
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the multiple post.

is there any solution to allow the browser to display the string as xml format?


thanks!
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to do something like this. anybody know if it is possible? thanks!

http://www.w3schools.com/XML/note.xml


 
Marshal
Posts: 80871
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a "beginner's" question. Moving.
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "application/xml" supposed to mean? Why not just "text/xml" for the MIME type?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

s there any solution to allow the browser to display the string as xml format?



Sure - you can substitute escaped characters for the < and > used to delineate xml tags, you can use the method in String class but it would be kind of time consuming for so many tags. The browser will display < and > in place of the excaped character string.

This ranch FAQ gives one example of "pretty printing" XML with indentation but I found more with a google search "java pretty print xml"

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic