• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLConnection returning html output instead of XML

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

I have a url where the content is XML and it has XSL file specified. Now, when I go to that url from the browser and do view source I see the XML data BUT from the java program when I make connection and read the data via BufferedReader I get HTML (that means somewhere its making XSL applied).

I tried to set property "content-type" as "text/xml" on the URLConnection but it still gives me the HTML output.

Here is the code,


How can I get the XML output?

Regards
Maulin
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want only XML check your XML file for the code

<?xml-stylesheet type="text/xsl" href="some xsl file name"?>

delete this line from xml file.

This may resolve ur problem.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pandoo,

Deleting the xsl declaration is not possible for me as I can't control xml generation

Will keep looking for ways...and of course keep JR updated..

Regards
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh btw,

I just realized that it was so stupid to set content type to be xml. I am reading data, not writing it so its wrong to set content type

At this point, I am having a question. I always thought that when we have this XSL applied to the XML , browser downloads the XML and then applies the XSL over it to display data in whatever format. Hence I thought if I make a URLConnection it would just give me the XML data as I don't have transformation applied but when I print ContentType from the URLConnection it gives me text/html which means the data is converted to html already...

Can anybody explain what exactly happens here?

Regards
Maulin
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic