Can't read from XML


Last Updated:

  1. orelzion

    orelzion New Member This Topic's Starter

    Joined:
    Oct 9, 2010
    Messages:
    1
    Likes Received:
    0
    It just keep giving me "Permission denied" error.
    Here's my code.

    Code (Text):
    1.  
    2.    private RSSFeed getFeed(String urlToRssFeed)
    3.     {
    4.         URL url=null;
    5.         try
    6.         {
    7.             // setup the url
    8.             url = new URL(urlToRssFeed);
    9.  
    10.            // create the factory
    11.            SAXParserFactory factory = SAXParserFactory.newInstance();
    12.            
    13.            // create a parser
    14.            SAXParser parser = factory.newSAXParser();
    15.  
    16.            // create the reader (scanner)
    17.            XMLReader xmlreader = parser.getXMLReader();
    18.  
    19.            // instantiate our handler
    20.            RSSHandler theRssHandler = new RSSHandler();
    21.            
    22.            // assign our handler
    23.            xmlreader.setContentHandler(theRssHandler);
    24.  
    25.            // get our data through the url class
    26.            xmlreader.parse(new InputSource(url.openStream()));        
    27.            
    28.            // get the results - should be a fully populated RSSFeed instance,
    29.            // or null on error
    30.            return theRssHandler.getFeed();
    31.         }
    32.         catch (Exception ee)
    33.         {
    34.             // if you have a problem, simply return null
    35.               new AlertDialog.Builder(this)
    36.             .setMessage(ee.getMessage()).show();
    37.            
    38.             return null;
    39.         }
    40.     }
    41.  
     

    Advertisement

Share This Page

Loading...