Last active
August 29, 2015 14:13
-
-
Save thebouv/e48265d9b44ab0d9f18b to your computer and use it in GitHub Desktop.
Parsing XML with namespace (such as slash:comments)
This file contains 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
el[0].getElementsByTagNameNS('http://purl.org/rss/1.0/modules/slash/', 'comments')[0].innerHTML; | |
// or a fuller example | |
$.get('/blogfeed.php', function (data) { | |
var count = 1; | |
$(data).find("item").each(function () { | |
var el = $(this); | |
// ... | |
// how many comments | |
// textContent must be used instead of innerHTML because webkit returns a NodeList instead of HTMLCollection, and NodeList | |
// apparently doesn't have innertHTML as a property of the element | |
var commentCount = parseInt(el[0].getElementsByTagNameNS('http://purl.org/rss/1.0/modules/slash/', 'comments')[0].textContent); | |
// ... | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment