java - How to find the given string is a RSS feed or not -
java - How to find the given string is a RSS feed or not -
i have string takes both xml , html input info downloaded given url. want check whether downloaded string rss feed of html document before parsing through saxparser. how find this?
for example
if download info http://rss.cnn.com/rss/edition.rss resulting string rss feed
if download info http://edition.cnn.com/2014/06/19/opinion/iraq-neocons-wearing/index.html resulting string html document.
i want go on process if string rss feed.
rss , html both subsets of xml. can obtain info xml , validate against rss xsd. this.
url schemafile = new url("http://europa.eu/rapid/conf/rss20.xsd"); source xmlfile = new streamsource(your_url_here); schemafactory schemafactory = schemafactory .newinstance(xmlconstants.w3c_xml_schema_ns_uri); schema schema = schemafactory.newschema(schemafile); validator validator = schema.newvalidator(); seek { validator.validate(xmlfile); // @ line can sure it's rss 2.0 stream } grab (saxexception e) { // not rss }
if want check namely string, can check typical rss structure, root element, required element in . won't recommend it.
java xml regex rss feed
Comments
Post a Comment