XmlReader xmlreader = new XmlReader(connection.getInputStream()); feed = input.build(xmlreader); } catch (Exception e) {
URL feedSource = new URL("http://...."); feed = new SyndFeedInput().build(new XmlReader(feedSource)); List<SyndEntryImpl> entries = (List<SyndEntryImpl>)feed.getEntries(); for(SyndEntryImpl entry : entries){ System.out.println(entry.getDescription().getValue()); }
public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); InputStream in = new URL(feedUri).openStream(); SyndFeedInput input = new SyndFeedInput(); return input.build(new XmlReader(in)); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
public boolean romeLibraryExample(String address) { boolean ok = false; try{ URL url = new URL(address); HttpURLConnection httpcon = (HttpURLConnection)url.openConnection(); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(url)); ok = true; } catch (Exception exc){ exc.printStackTrace(); } return ok; }
public boolean tryFeed(String feedUrl) throws IOException,MalformedURLException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = null; try { feed = input.build(new XmlReader(new URL(feedUrl))); return true; } catch (FeedException e) { // Feed's invalid return false; } }
byte[] data = ... bytes for the feed ... SyndFeedInput input = new SyndFeedInput() input.allowDoctypes = true SyndFeed sf = input.build(new XmlReader(new ByteArrayInputStream(data))) Document doc = new MyWireFeedInput().getDocument(new XmlReader(new ByteArrayInputStream(data))) Element channel = doc.rootElement.getChild("channel") List<Element> items = channel ? channel.getChildren("item") : null List<SyndEntry> entries = sf.entries for (int i = 0; i < entries.size(); i++) { SyndEntry entry = entries[i] Element item = items ? items[i] : null if (item) { Element image = item.getChild("image") ... add it to enclosures or whatever ... } }
public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); URL feedUrl = new URL(feedUri); HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection(); String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes()); httpcon.setRequestProperty ("Authorization", "Basic " + encoding); SyndFeedInput input = new SyndFeedInput(); return input.build(new XmlReader(httpcon)); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
URL feedUrl = new URL("http://the.url.to/the/feed"); //URL feedUrl = new URL("http://user:pass@the.url.to/the/feed"); HttpURLConnection connection = (HttpURLConnection) feedUrl.openConnection(); if (feedUrl.getUserInfo() != null) { String encoding = new sun.misc.BASE64Encoder().encode(feedUrl.getUserInfo().getBytes()); connection.setRequestProperty("Authorization", "Basic " + encoding); } SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(connection));
private SyndFeed readSyndFeedFromStream(InputStream inputStream, URLConnection connection) throws IOException, IllegalArgumentException, FeedException { BufferedInputStream is; if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) { // handle gzip encoded content is = new BufferedInputStream(new GZIPInputStream(inputStream)); } else { is = new BufferedInputStream(inputStream); } //InputStreamReader reader = new InputStreamReader(is, ResponseHandler.getCharacterEncoding(connection)); //SyndFeedInput input = new SyndFeedInput(); XmlReader reader = null; if (connection.getHeaderField("Content-Type") != null) { reader = new XmlReader(is, connection.getHeaderField("Content-Type"), true); } else { reader = new XmlReader(is, true); } SyndFeedInput syndFeedInput = new SyndFeedInput(); syndFeedInput.setPreserveWireFeed(isPreserveWireFeed()); return syndFeedInput.build(reader); }
URL feedUrl = new URL(feed) HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection(); String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes()); httpcon.setRequestProperty ("Authorization", "Basic " + encoding); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(httpcon));
URL feedUrl = new URL("http://www.bloomberg.com/tvradio/podcast/cat_markets.xml"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); for (Iterator i = feed.getEntries().iterator(); i.hasNext();) { SyndEntry entry = (SyndEntry) i.next(); System.out.println("title |"+entry.getTitle()+" " -timeStamp "+entry.getPublishedDate()"\n") }
private static FeedResponse validate(String feedRequestUrl) { try { URL url = new URL(feedRequestUrl); SyndFeedInput input = new SyndFeedInput(); input.build(new XmlReader(url)); //ensure request is a valid rss feed return FeedResponse.valid(feedRequestUrl); } catch (Exception e) { logger.debug("could not parse feed request {}, reason {}", feedRequestUrl, e.getMessage()); return FeedResponse.invalid(e.getMessage(), feedRequestUrl); } }
URL url = new URL("http://feeds.feedburner.com/javatipsfeed"); XmlReader reader = null; try { reader = new XmlReader(url); SyndFeed feeder = new SyndFeedInput().build(reader); System.out.println("Feed Title: "+ feeder.getAuthor()); for (Iterator i = feeder.getEntries().iterator(); i.hasNext();) { SyndEntry syndEntry = (SyndEntry) i.next(); System.out.println(syndEntry.getTitle()); } } finally { if (reader != null) reader.close(); }
public void loadQuests() { XmlReader r = new XmlReader(); Element e = null; try { e = r.parse(Gdx.files.internal("quest/quest.xml")); } catch (IOException a) { } if (e != null) { for (int i = 0; i < e.getChildCount(); i++) { m_quests.add(new Quest(e.getChild(i))); //has reference to the core class } } }
public static RufusFeed generate(Source source) { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = null; URL url = source.getUrl(); try { feed = input.build(new XmlReader(url)); } catch (Exception e) { logger.debug("Could not build SyndFeedInput for {}", url, e); } if (CollectionUtils.isEmpty(source.getTags())) { source.setTags(Collections.emptyList()); //never null! } return new RufusFeed(source, feed); }
public static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRss(datasetOrig); try { feed = input.build(new XmlReader(new URL(rss))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { datasets.add(datasetFor(datasetOrig, (SyndEntry) entry)); } } return datasets; }
XmlReader r = new XmlReader(); Element e = r.parse(xml);//<--- the XML as string also possible as file for (int i = 0; i < e.getChildCount(); i++) { Element child = e.getChild(i); switch(child.getName()){ case "sampleimplement1": //create sample1 break; .... .... }
/** * Reads a feed and returns the ROME SyndFeed object that was created by * reading the feed. Note that this method blocks, and should be called * on a background thread. * * @return the feed * @throws RSSException if something goes wrong while accessing the RSS feed */ public SyndFeed readFeed() throws RSSException { try { URL feedUrl = constructUrl(); SyndFeedInput input = new SyndFeedInput(); return input.build(new XmlReader(feedUrl)); } catch (Exception e) { throw new RSSException(e); } } }
public static SyndFeed getFeed( String feedId ) throws IllegalArgumentException, MalformedURLException, FeedException, IOException { SyndFeedInput input = new SyndFeedInput(); Response response = RequestFacade.sendMessage( FEED_URL_PART + feedId, Method.GET ); Assert.assertTrue( "Expected content", response.getEntity().isAvailable()); SyndFeed feed = input.build( new XmlReader( response.getEntity().getStream() ) ); // sort it by date sortSyndEntryOrderByPublishedDate( feed ); return feed; }
XmlReader xml = new XmlReader(); try { // Element is the root element of your document, i.e. <levels> XmlReader.Element element = xml.parse(Gdx.files.internal("D:\\someFolder\\android\\assets\\levels.xml")); currentLevel = element.getInt("currentLevel"); XmlReader.Element level = element.getChildByName("Level1"); lineAngle = level.getInt("lineAngle"); speed = level.getFloat("speed"); direction = level.getInt("direction"); } catch (Exception e) { }