Last active
December 16, 2015 20:11
jQuery Parse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://api.jquery.com/jQuery.parseXML/ --> | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>jQuery.parseXML demo</title> | |
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> | |
</head> | |
<body> | |
<p id="someElement"></p> | |
<p id="anotherElement"></p> | |
<script> | |
var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>", | |
xmlDoc = $.parseXML( xml ), | |
$xml = $( xmlDoc ), | |
$title = $xml.find( "title" ); | |
// Append "RSS Title" to #someElement | |
$( "#someElement" ).append( $title.text() ); | |
// Change the title to "XML Title" | |
$title.text( "XML Title" ); | |
// Append "XML Title" to #anotherElement | |
$( "#anotherElement" ).append( $title.text() ); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/226663/parse-rss-with-jquery | |
function parseRSS(url, callback) { | |
$.ajax({ | |
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url), | |
dataType: 'json', | |
success: function(data) { | |
callback(data.responseData.feed); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment