PDA

View Full Version : JAVA and XML


mxb7642
08-03-2007, 02:48 PM
I am trying to retrieve the xml data for a website. When I look at the source for the site I see xml, however, when I try to retrieve it using java, I get back html. I've tried two techniques so far:


tidy = new Tidy();
tidy.setXHTML(true);
tidy.setShowWarnings(false);
tidy.setQuiet(true);
url = new URL( urlString );
connection = (HttpURLConnection)url.openConnection();
InputStream in = connection.getInputStream();



SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
sp = spf.newSAXParser();
URL url = new URL( urlString );
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
in = connection.getInputStream();


Is there something wrong with my code? Or should I be using a different technique? Thanks for the help ahead of time.

cash1981
08-10-2007, 02:47 PM
If urlString has a xml value then you should be able to use SAX or DOM to retrieve the data.