parse start before download XML

Put your problem here if it does not fit any of the other categories.

parse start before download XML

Postby FrunK » Sun Nov 07, 2010 8:34 am

Hi guys,

I'm trying to parse a XML file from an URL, I used the code from one of plusminus tutorials.
The XML always show the same number of items and the tag's are well formed.

The problem is that I had a less number of items than expected (can change when restarting the app). I see that the SAX start to parse an truncanted XML. I save and upload it to
another server and I get more items but not all, If I restart the app and parse again this save version, then I can got different numbers of item :S

I think is because server time response, but I dont know how start to parse just when the whole XML is load.



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. /* Get a SAXParser from the SAXPArserFactory. */
  2.                                 SAXParserFactory spf = SAXParserFactory.newInstance();
  3.                                 SAXParser sp = spf.newSAXParser();
  4.  
  5.                                 /* Get the XMLReader of the SAXParser we created. */
  6.                                 XMLReader xr = sp.getXMLReader();
  7.                                 xr.setContentHandler(myExampleHandler);
  8.                                                                                
  9.                                 xr.parse(new InputSource(url.openStream()));
  10.                                
  11.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
FrunK
Freshman
Freshman
 
Posts: 2
Joined: Sun Nov 07, 2010 2:13 am

Top

Re: parse start before download XML

Postby techkanika » Mon Nov 08, 2010 11:36 am

Hi FrunK..

look at the following link.. hope it will help you..

http://developerspoint.wordpress.com/2008/06/23/parsing-xml-in-java-using-sax/

Thanks
Kanika
Thanks
Kanika Rakheja
User avatar
techkanika
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Fri May 28, 2010 7:49 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 10 guests