How to use jquery to find xml element with ':' in name? [duplicate]




This question already has an answer here:




I'm trying to use jquery to parse and find an xml element. The element I'm trying to find has an odd name "ex:relatedid" and for some reason jquery seems to not be able to find it. Any ideas? Thanks in advance!


XML



<item>
<id>3ac0daff-51c7-40f2-9396-e0c6adf50858</id>
<published>2014-12-09T11:27:43.000Z</published>
<updated>2014-12-09T11:27:43.000Z</updated>
<ex:relatedid>7fa16377-3382-4ad9-ac52-7ee139e7d9ce</relatedid>


jquery that doesn't work



$(xml).find('item').each(function () {

//works
var id = $(this).find('id').text();

//doesn't work
var ex = $(this).find('ex:relatedid').text();

console.log(ex);

});

No comments:

Post a Comment