1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <html> <head> <title>jQuery XML workbench</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="workbench.js"></script> <script type="text/javascript" src="home.js"></script> <!-- Put the XML file or URL in the href attribute below: --> <link href="atom1.xml" type="application/xml" rel="target_XML" /> </head> <body> <h1>Caesar's home page</h1> <p>GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. </p> <p>Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. </p> <p>Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.</p> <h2>My <a href="feed.xml">Web feed</a></h2> <div id="update-target"></div> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" xml:base="http://www.example.org"> <id>http://www.example.org/myfeed</id> <title>My Simple Feed</title> <updated>2005-07-15T12:00:00Z</updated> <link href="/blog" /> <link rel="self" href="/myfeed" /> <author><name>Uche Ogbuji</name></author> <entry> <id>http://www.example.org/entries/1</id> <title>A simple blog entry</title> <link href="/blog/2005/07/1" /> <updated>2005-07-14T12:00:00Z</updated> <summary>This is a simple blog entry</summary> </entry> <entry> <id>http://www.example.org/entries/2</id> <title /> <link href="/blog/2005/07/2" /> <updated>2005-07-15T12:00:00Z</updated> <summary>This is simple blog entry without a title</summary> </entry> </feed> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* home.js */ var ATOM_NS = 'http://www.w3.org/2005/Atom'; function xml_ready(result){ var xml = result.responseXML; //Make sure the target area for inserting data is clear $("#update-target").empty(); $(xml).find('*').ns_filter(ATOM_NS, 'entry').each(function(){ var title_elem = $(this).find('*').ns_filter(ATOM_NS, 'title').clone(); var link_text = $(this).find('[rel="alternate"]') .ns_filter(ATOM_NS, 'link') .attr('href'); var summary_elem = $(this).find('*').ns_filter(ATOM_NS, 'summary').clone(); //Deal with the case of a missing title if (!title_elem.text()){ title_elem = '[No title]'; } //Deal with the case where rel='alternate' is omitted if (!link_text){ link_text = $(this).find('*') .ns_filter(ATOM_NS, 'link') .not('[rel]') .attr('href'); } //Update the target area with the entry information $('<p></p>') .append( $('<a href="' + link_text + '"></a>') .append(title_elem) ) .append(' - ') .append(summary_elem.clone()) .fadeIn('slow') //bonus animation .appendTo('#update-target'); }); //close each( } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |