Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 234493

Re: Calling context node E4X functions inside filter expression.

$
0
0

Hi,

 

You can achieve similar results by defining a custom filter function. Something like:


function filter(list, predicate) {

    var result = new XMLList();

    var k = 0;

    for (var i = 0; i < list.length(); i++) {

        if (predicate(list[i])) {

           result[k++] = list[i];

        }

    }

    return result;

}

 

And then calling it:

  var filteredList = filter(e4xList.item, function(x){return x.childIndex() < 3;});

 

Not as elegant as the one-line filter, but works.

 

Hope this helps,

-Ilian


Viewing all articles
Browse latest Browse all 234493

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>