I have a string like this:
<note><url>urlofpage1</url><notes>These are the Notes of Page 1</notes></note>
<note><url>urlofpage2</url><notes>These are the Notes of Page 2</notes></note>
I’ve been trying to parse it so I can get the notes based on the URL:
so
notesofpage1 = getNotes(‘urlofpage1’)
Here’s one thing I tried but it doesn’t work for some reason.
var xml = '<note><url>urlofpage1</url><notes>These notes should load!</notes></note><note><url>urlofpage2</url><notes>These are the Notes of Page 2</notes></note>';
var $xml = $(xml);
var $notes = $xml.find('url')
.filter(function() { return $(this).text() == 'urlofpage1' })
.closest('notes');
Any ideas what i’m doing wrong?
http://jsfiddle.net/kqMhk/1/