sorting xml in javascript/jquery -
I was trying to sort some XML with jquery, but this code does not affect the actual XML or sort Returning results is not returning.
Is anything wrong with this code?
$ (xml) .find ('tag'). Get () Sort (function (a, b) {return $ (A) .find ('name'). Text () & lt; $ (b) .find ('name'). Text ()? -1: 1;} );
creates matching functions and returns the array, then your code again this array What changes, then? The array is not referred anywhere, so it is only dropped.
I suspect that you are expecting a source XML document to be mutated in order to represent this type. Are you sure you want to change XML or reach the sorted ARF?
var sortedSet = $ (xml). Find ('Tag'). Get () Sort (function (a, b) {var valA = $ (a) .find ('name'). Text (); var valB = $ (b) .find ('name') .txt (); return valA & Lt; valB? -1: walay == walb? 0: 1;});
It is a bit easier to replace XML, especially if "tag" is found deeper than xml direct child.
Comments
Post a Comment