jQuery won't parse xml with nodes called option
Posted
by user170902
on Stack Overflow
See other posts from Stack Overflow
or by user170902
Published on 2010-05-25T22:10:12Z
Indexed on
2010/05/25
22:21 UTC
Read the original article
Hit count: 159
hi all,
I'm using jQuery to parse some XML, like so:
function enumOptions(xml) {
$(xml).find("animal").each(function(){
alert($(this).text());
});
}
enumOptions("<root><animal>cow</animal><animal>squirrel</animal></root>");
This works great. However if I try and look for nodes called "option" then it doesn't work:
function enumOptions(xml) {
$(xml).find("option").each(function(){
alert($(this).text());
});
}
enumOptions("<root><option>cow</option><option>squirrel</option></root>");
There's no error, just nothing gets alerted, as if the find isn't finding anything. It only does it for nodes called option everything else I tested works ok!
I'm using the current version of jQuery - 1.4.2.
Anyone any idea?
TIA.
bg
© Stack Overflow or respective owner