Skip to content

Instantly share code, notes, and snippets.

@scriptmediala
Last active December 16, 2015 20:11
Show Gist options
  • Save scriptmediala/797cefc9e6723e657b8a to your computer and use it in GitHub Desktop.
Save scriptmediala/797cefc9e6723e657b8a to your computer and use it in GitHub Desktop.
jQuery Parse
<!-- 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>
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