making shorter the source parsing xml in jquery

WTFDang <3

New Member
This is what i parsed from xml, but it's too long. Does anyone know how to make it shorter?there is a change of the number at "charList()" and structure of "if".\[code\]var charList1;var charList2; var charList3;\[/code\] \[code\]var charList4; var charList5;\[/code\]\[code\]$.ajax({ type: "get", url: "XMLFile1.xml", async: false, dataType: "xml", success: function (xml) { $(xml).find('list').each(function () { obj = $(this).find("title"); if (obj.text() == "1") { charList1 = (obj.next().text()); } else if (obj.text() == "2") { charList2 = (obj.next().text()); } else if (obj.text() == "3") { charList2 = (obj.next().text()); } else if (obj.text() == "4") { charList2 = (obj.next().text()); } else if (obj.text() == "5") { charList2 = (obj.next().text()); } }); }});\[/code\]
 
Back
Top