[SOLVED]beginners question about using xml with jQuery
hi all
i can't find how to get the text of an xml element, just like the code bellow
-
$("qa", xml).each(
function(qa_idx) {
qa = $("qa", xml).get(qa_idx);
$("choice", qa).each(
function(ch_idx) {
choice = $(this).text(); //the text
description = $("choice_desc", qa).get(ch_idx).text();//doesn't work
}
);
}
);
from an xml like
-
<qa>
<question>1st question</question>
<choice id="1">Adventurous</choice>
<choice_desc>desc 1</choice_desc>
<choice id="2" checked="checked">Adaptable</choice>
<choice_desc>desc 2</choice_desc>
<choice id="4">Animated</choice>
<choice_desc>desc 3</choice_desc>
<choice id="5">Analytical</choice>
<choice_desc>desc 4</choice_desc>
</qa>
what is the method to get the text? i can't seem found any sample for this
-----
The solution
-
description = $($("choice_desc", qa).get(ch_idx)).text();
