What is ry? (2)

xiaoxiao2021-03-06  14

What is rss? By Mark Pilgrim | Pages: 1, 2

Despite being RDF / XML, RSS 1.0 is structurally similar to previous versions of RSS - similar enough that we can simply treat it as XML and write a single function to extract information out of either an RSS 0.91 or RSS 1.0 feed However, there. Area Significant Differences That Our Code Will Need To Be aware of:

The root element is rdf:. RDF instead of rss We'll either need to handle both explicitly or just ignore the name of the root element altogether and blindly look for useful information inside it.RSS 1.0 uses namespaces extensively The RSS 1.0 namespace is. Http://purl.org/rss/1.0/, and it's defined as the default namespace. The feed also buy http://www.w3.org/1999/02/22-rdf-syntax-ns# for the rdf -Specific Elements (Which Weames) and http://purl.org/dc/elements/1.1/ (DUBLIN CORE) for the additional metadata of article authors and publish dates.we can go in one of two ways here: if we do not have a namespace-aware XML parser, we can blindly assume that the feed uses the standard prefixes and default namespace and look for item elements and dc:. creator elements within them This will actually work in A large number of real-world case; MOST RSS feeds use the default namespace and the Same prefixes for Common Modules Like Dublin Core. this is a horrible h Ack, though. There's no guarantee That a feed Won't use a different prefix for a namespace (Which Would Be Perfectly Valid XML and RDF). IF or When It Does, We'll Miss It.if We Have A Namespace-Aware XML Parser At Our Disposal, We can construct A More Elegant Solution That Handles Both RSS 0.91 and 1.0 feeds. We can ike for items in no namespace;

IF That Fails, We can Items in the RSS 1.0 Namespace. (Not Shown, But RSS 0.90 Feeds Also Use A Namespace, But Not The Same ONE AS RSS 1.0. So What We Really NEED IS A List of Namespaces To Search. ) Less obvious but still important, the item elements are outside the channel element (in RSS 0.91, the item elements were inside the channel in RSS 0.90, they were outside;.... in RSS 2.0, they're inside Whee) So we can not be picky about where we look for items.Finally, you'll notice there is an extra items element within the channel. It's only useful to RDF parsers, and we're going to ignore it and assume that the order of the items within the RSS feed is given by their order of the item elements.But what about RSS 2.0? luckily, once we've written code to handle RSS 0.91 and 1.0, RSS 2.0 is a piece of cake. Here's the RSS 2.0 version Of The Same Feed:

xml.com </ title> <link> http: // www. Xml.com / </ link> <description> XML.com Features a Rich Mix of Information and Services for the XML Community. </ description> <Language> En-US </ Language> <item> <title> Normalizing XML, Part 2 </ title> <link> http://www.xml.com/pub/a/2002/12/04/normalization.html </ link> <description> in this second and final look at Applying Relational Normalization Techniques, THIS to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms </ description>. <dc: creator> Will Provost </ dc: creator> <dc: date> 2002 -12-04 </ dc: Date> </ item> <item> <title> The .NET Schema Object Model </ title> <link> http://www.xml.com/pub/a/2002/12 / 04/som.html </ link> <description> Priya Lakshminarayanan Describes in detil the use of the .net schema Object Model for Programmatic Manipulation O F W3C XML Schemas. </ Description> <dc: Creator> Priya Lakshminarayanan </ dc: Creat> <DC: DATE> 2002-12-04 <Item: DATE> </ item> <item> <title> svg's paste And Promising Future </ title> <link> http://www.xml.com/pub/a/2002/12/04/svg.html </ link> <description> in this Month's Svg Column, Antoine Quint Looks Back At Svg's Journey THROUGH 2002 and Looks Forward to 2003. </ Description> <DC: Creator> Antoine Quint </ dc: Creator> <</p> <p>DC: DATE> 2002-12-04 </ DC: DATE> </ ITEM> </ channel> </ rss> As this Example Shows, RSS 2.0 Uses Namespaces Like RSS 1.0, But It's Not Rdf. Like RSS 0.91, There IS NO Default Namespace and Items Are Back Inside The Channel. IF out Is LibERAL ENOUGH To Handle The Differences Between RSS 0.91 and 1.0, RSS 2.0 Should Not Present Any Additional Wrinkles.</p> <p>How Can I Read RSS?</p> <p>Now let's get down to actually reading these sample RSS feeds from Python The first thing we'll need to do is download some RSS feeds This is simple in Python;.. Most distributions come with both a URL retrieval library and an XML parser (. Note to Mac OS X 10.2 Users: your copy of python does NOT COME WITH AN XML PARSER; You will need to install pyxml first.)</p> <p>From xml.dom import minidomimport urllibdef loading (rsssurl): return minidom.parse (Urllib.urlopen (Rssurl))</p> <p>This Takes The Url of an RSS feed and return a parse 帖子 帖子 OF AS NATIVE PYTHON Objects.</p> <p>The next bit is the tricky part. To compensate for the differences in RSS formats, we'll need a function that searches for specific elements in any number of namespaces. Python's XML library includes a getElementsByTagNameNS which takes a namespace and a tag name, so we'll use that to make our code general enough to handle RSS 0.9x / 2.0 (which has no default namespace), RSS 1.0 and even RSS 0.90. This function will find all elements with a given name, anywhere within a node. that's ........................ ..</p> <p>Default_namespaces = / (none, # rss 0.91, 0.92, 0.93, 0.94, 2.0 'http://purl.org/rss/1.0/', # rss 1.0 'http://my.netscape.com/rdf/simple/ 0.9 / '# RSS 0.90) def getElementsByTagName (node, tagName, possibleNamespaces = DEFAULT_NAMESPACES): for namespace in possibleNamespaces: children = node.getElementsByTagNameNS (namespace, tagName) if len (children): return children return [] Finally, we need two utility functions to make our lives easier. First, our getElementsByTagName function will return a list of elements, but most of the time we know there's only going to be one. An item only has one title, one link, one description, and so on . We'll define a first function that returns the first element of a given name (again, searching across several different namespaces). Second, Python's XML libraries are great at parsing an XML document into nodes, but not that helpful at putting the data Back together again. We'll Define a Textof Function That Returns The Entire Text of a Particular XML ELEMENT.</p> <p>def first (node, tagName, possibleNamespaces = DEFAULT_NAMESPACES): children = getElementsByTagName (node, tagName, possibleNamespaces) return len (children) and children [0] or Nonedef textOf (node): return node and "" .join ([child. Data for child in node.childnodes]) OR ""</p> <p>That's it. The actual paarsing is easy. We'll Take a Url on The Command Line, Download IT, Parse It, Get The List of items, and the get some useful information from Each Item:</p> <p>DUBLIN_CORE = ('http://purl.org/dc/elements/1.1/' ,)if __name__ == '__main__': import sys rssdocument = loading (sys.argv [1]) for item in getElementsBytagname (RssDocument, ' item '): Print' Title: ', Textof (Item,' Title ')) Print' Link: ', Textof (Item,' Link ')) Print' Description: ', Textof (item, 'Description')) Print 'Date:', Textof (Item, 'Date', Dublin_CORE) Print 'Author:', Textof (Item, 'Creat', Dublin_CORE) Printrunning It With Our Sample RSS 0.91 Feed Prints Only Title, Link, And Description (Since The Feed Didn't Include ANY Other Information on Dates or Authors):</p> <p>$ Python Rss1.py http://www.xml.com/2002/12/18/examples/rs091.xml.txtTtitle: Normalizing XML, Part 2 Link: http://www.xml.com/pub/a/2002 /12/04/normalizing.htmldescription: In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.date: author : title: The .NET Schema Object Modellink: http://www.xml.com/pub/a/2002/12/04/som.htmldescription: Priya Lakshminarayanan describes in detail the use of the .NET Schema Object Model for programmatic Manipulation of W3C XML Schemas.date: Author: Title: Svg's Past and Promising FutureLink: http://www.xml.com/pub/a/2002/04/svg.htmldescription: in this Month's Svg Column, Antoine Quint Looks Back At Svg's Journey THROUGH 2002 and Looks Forward to 2003.Date: Author:</p> <p>For both the sample RSS 1.0 feed and sample RSS 2.0 feed, we also get dates and authors for each item. We reuse our custom getElementsByTagName function, but pass in the Dublin Core namespace and appropriate tag name. We could reuse this same function to extract . information from any of the basic RSS modules (There are a few advanced modules specific to RSS 1.0 that would require a full RDF parser, but they are not widely deployed in public RSS feeds.) Here's the output against our sample RSS 1.0 feed:</p> <p>$ Python Rss1.py http://www.xml.com/2002/12/18/examples/rss10.xml.txttitle: Normalizing XML, Part 2 Link: http://www.xml.com/pub/a/2002 /12/04/normalizing.htmldescription: In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.date: 2002 -12-04Author: Will ProvostTitle: The .Net Schema Object Modellink: http://www.xml.com/pub/a/2002/12/04/som.htmldescription: priya lakedshminarayanan describes in detail the user of the .net Schema Object Model for programmatic manipulation of W3C XML Schemas.date: 2002-12-04author: Priya Lakshminarayanantitle: SVG's Past and Promising Futurelink: http://www.xml.com/pub/a/2002/12/04/svg. HTMLDESCRIPTION: INTH's SVG Column, Antoine Quint Looks Back At Svg's Journey Through 2002 and Looks Forward to 2003.Date: 2002-12-04author: Antoine Quint</p> <p>Running Against Our Sample RSS 2.0 Feed Products The Same Results.</p> <p>This technique will handle about 90% of the RSS feeds out there; the rest are ill-formed in a variety of interesting ways, mostly caused by non-XML-aware publishing tools building feeds out of templates and not respecting basic XML well-formedness Rules. Next Month We'll Tackle The Thorny Problem of How To Handle Rss Feeds That Are Almost, But Not Quite, Well-Formed Xml.related Resources</p> <p>Sample RSS feeds: RSS 0.91, RSS 1.0, RSS 2.0 rss1.py Specifications:. RSS 0.90, RSS 0.91, RSS 1.0, RSS 2.0 Syndic8.com, a directory of 10,000 publicly available RSS feeds News Readers in the Open Directory,.. A Variety of Client-Side and Server-Side Programs forreading RSS feeds.</p> <p>Are you use rss in your web or xml processs? Share Your Experience IN Our Forum. (* You Must Be a member of xml.com to use this feature.) Comment On this article</p> <p>MEMBER OF XML.com to use this feature.)</p> <p>Comment on this article</p> <p>Titles ONLY TITLES ONLY NEWEST FIRST</p> <p>Your article helped me -2005-03-06 08:25:14 Katykoot [reply] i Just Want to make Sure I Did it right. I am hoping this my feed.rs Will be picked up by news agencies and sydicated. Can you Check it for me ... and by looking at this - IS this the correct way to be doing a press release ... by rss? Versus prweb.com? http://www.amethystlive.com/feed.rss</p> <p>My Company Doesn't Want RSS2004-04-07 08:47:00 Raleing to get my company to get ket fs feeds .... Their reply: >> however, we are Holding Off on Deploying Them in a widespread fashion >> while we craft a general strategy for syndication and mobility. Though >> RSS feeds may be useful in news aggregators, and could increase page >> views to articles, the risk is that they may actually reduce page >> views To Our Own Index Pages, Which Carry Display Advertising That RSS >> Inherently Cannot. How Can I Argue this? What to say? my company doesn't want ry m company doesn't want r m m 帖子 @ 20T \ RSS feed often contains only the opening paragraph (or short teaser / summary) of each posted article (or announcement or whatever). The bulk of the article is generally kept on the Web site, the URL for which is included in the RSS feed, So That Users Who Are Intested Can Click THROUGH AND Read The Whole Thing. So, Your Rss Feed IS Basical Another Way for Uses To Subscribe to announcements of new articles, features, etc., for which they still have to come to your site, and view your pages (and ads) in order to view the whole article. (Kinda like direct-emailing of new article announcements, but Easier.)</p> <p>MY Company Doesn't Want RSS2004-06-27 00:35:47 Gregman [Reply] Easy, Get The To Put Ads on The Content Pages Just Like this site.</p> <p>My Company Doesn't Want RSS2004-06-11 09:09:38 Prakashnambiar [Reply] Hey, You Can Deliver An Advt with The Image / Logo of Your Rss Feed, Stil You Can Use The Comments Tag !!!</p> <p>Please Don't Break XML! 2003-01-03 01:35:35 Henri sivonen [reply] Using the namespace previceing is dirty. Getting a namespace-aware XML Parser is not this hard. Please don't break namespaces by using prefix-based guessing Even more worrying is the last sentence:. "Next month we'll tackle the thorny problem of how to handle RSS feeds that are almost, but not quite, well-formed XML." What's there to tackle? The only correct way to handle ill-formed XML is to firmly reject it. Please enforce the XML well-formedness requirements in order to protect XML from degenerating into tag soup.Please do not break XML! 2005-01-19 04 : 20: 03 Looking_past_XML [Reply] Oh my freakin 'god, XML is not a sacred standard, shit happens, the offical W3C docs encourage browser / user-agent creators to attempt to properly render imperfect html / xhtml The spirit of RFC's and. Protocols That Has Made The Internet Work (able) IS: "Be Liberal in What You Accept and Conservation In What you send "and it's variations by Jon Postel. Also, TOG et al would probably assail a system that was so anal and rigid and non-resilient (and they would say lazy) that it could not route around some minor formatting transgressions and give the user 50%, 80% or whatever percent of the feed that it could decipher.But this brings up the elephant that no one is allowed to talk about -. XML and it's main parsers are extremely brittle and complex Flame on ...</p> <p>! Please do not break XML 2005-01-19 04:33:16 Looking_past_XML [Reply] Since people may not get the "TOG" reference: TOG - usability expert that puts much more responsibility on the system creators for making systems that " Just Work "than many programmers would like, after reading too much of his stuff start thinking" Wow, programs should do a lot better job for the user in many cases "http://www.asktog.com/Bughouse/10MostPersistentBugs.htmlPlease Don't Break XML! 2005-01-11 05:27:50 DESPIL [Reply] I Absolutely agree. What is the place in making standards if we throw the ire the window so uasily? Either don't make Standards or use them .There is no third way.</p> <p>RDF makes life difficult2002-12-19 12:39:02 Mario Diana [Reply] If there is some reason that sites wish to use RDF, they ought to include a XSL transformation of the document to RSS. Is that really so difficult? I Was Writing a Web Service To Gather An RSS Feed From A Client And Return Transformed HTML. WHEN I RAN INTO RDF, I WAS Completely Thrown. (Okay, Maybe I Live Under A Rock.) RDF Is for Machines; RSS Is Far More Human -Friendly. It's a pain to have to deal with it if you're not intended in its features.</p> <p>Rdf Makes Life Difficult2004-09-24 13:06:41 KES [Reply] Can you tell me more about the project you are working on. It snouds realin ... and i would love to Learn more. Thanks-</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-47891.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="47891" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.048</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '093D1wgB0lMlL5fRiKgAFsGBm9yK1KKLDnRwIunmHuGU7RVE60HxgoTaDocmcCizGpkke0R3sryQZ_2FtqVUNgIg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>