Skip to content

Instantly share code, notes, and snippets.

@padde
Created July 10, 2012 08:59
Show Gist options
  • Save padde/3082143 to your computer and use it in GitHub Desktop.
Save padde/3082143 to your computer and use it in GitHub Desktop.
SO question #11409692
<?xml version="1.0" encoding="utf-8"?>
<item name="a">
<item name="d">
<item name="g"></item>
</item>
<item name="e"></item>
<item name="f"></item>
</item>
<item name="b"></item>
<item name="c"></item>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>SO Question #11409692</title>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('button').on('click', function(){
alert('parse');
$.ajax({
type: "GET",
url: "http://jsbin.com/imakap",
dataType: "xml",
success: function(xml) {
$(xml).filter('item').each(function(){
var name = $(this).find('name').text();
alert(name);
});
},
error: function(err) {
alert('error');
}
});
});
});
</script>
</head>
<body>
<button>Run</button>
<div id="result"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment