0
Я пишу небольшой код для синтаксического анализа XML в jQuery, но только один символ читается из атрибута info.XML Parsing - jQuery
XML:
<series srss="29">
<srs info="2300,Sheffield Shield 2014-15"/>
<srs info="2313,Ram Slam T20 Challenge 2014-15"/>
<srs info="2275,Pakistan vs New Zealand in UAE, 2014"/>
<srs info="2293,England tour of Sri Lanka, 2014"/>
<srs info="2310,Ranji Trophy, 2014-15"/>
<srs info="2278,India tour of Australia, 2014-15"/>
<srs info="2262,West Indies in South Africa, 2014-15"/>
<srs info="2302,Big Bash League 2014-15"/>
<srs info="2291,Sri Lanka tour of New Zealand, 2014-15"/>
<srs info="2279,India and England in Australia Tri-Series, 2015"/>
<srs info="2292,Pakistan tour of New Zealand, 2015"/>
<srs info="2325,WC Warm up matches, 2015"/>
<srs info="2223,WC 2015"/>
<srs info="2307,Irani Cup, 2015"/>
<srs info="2321,County Championship Division One 2015"/>
<srs info="2322,County Championship Division Two 2015"/>
<srs info="2320,England tour of West Indies, 2015"/>
<srs info="2323,NatWest t20 Blast, 2015"/>
<srs info="2284,New Zealand tour of England, 2015"/>
<srs info="2280,India tour of Bangladesh, 2015"/>
<srs info="2285,The Ashes, 2015"/>
<srs info="2324,Royal London One-Day Cup, 2015"/>
<srs info="2286,Australia tour of Ireland, 2015"/>
<srs info="2287,Australia tour of England, 2015"/>
<srs info="2281,T20 WC League, 2015"/>
<srs info="2282,South Africa tour of India, 2015"/>
<srs info="2283,Sri Lanka tour of India, 2015-16"/>
<srs info="2317,England tour of South Africa, 2015-16"/>
<srs info="2263,T20 WC 2016"/>
</series>
Код:
var i=0;
seriesArray = $(text).find('srs').attr('info'); //Returns 2300,Sheffield Shield 2014-15
//console.log(seriesArray);
var SeriesVal = $(text).find('srs').each(function(){
//console.log(this);
seriesArray[i] = $(this).attr('info'); //Returns 2 in first iteration, 3 in second iteration and so on
//console.log("Value = "+seriesArray[i]);
i=i+1;
});
застрял с этим, может быть что-то очень маленький тоже. Может кто-то помочь. Заранее спасибо