Forums

Sort XML Results (javascript)

Last post 01-18-2007, 11:58 AM by nfloyd. 1 replies.
Sort Posts: Previous Next

     12-19-2006, 8:08 AM 800

    Sort XML Results (javascript)

    Is there a call to DE that will return the results sorted?  I don't find this anywhere in the documentation.  It would be nice if this were added.

    In lieu of this not being a feature any suggestions on how to sort the returned xml (i.e. by members last name, etc.) using javascript.

    Thanks

    Mark
    | Filed under: , ,

     01-18-2007, 11:58 AM 919 in reply to 800

    Re: Sort XML Results (javascript)

    Currently there is no mechanism in the DataExchange Query Language to return the results sorted.  We think that your enhancement suggestion is an excellent idea and are moving to make the changes to DataExchange now for all methods.


     Depending on you implementation (i.e. how you are using the XML on your page) you should be able to come up with a XSLT solution something like the following in your xsl template would probably work:


    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="individuals">
        <table>
            <xsl:for-each select="individual">
                <xsl:sort select="@lastUpdatedDate" order="descending" />
                <xsl:if test="position() < 150">
                 <tr>
                     <td><xsl:value-of select="@firstName" /></td>
                     <td><xsl:value-of select="@lastName"/></td>
                 </tr>
                 </xsl:if>
            </xsl:for-each>
        </table>
    </xsl:template>
    </xsl:stylesheet>

    Let me know if you have any questions.

    --Nick

View as RSS news feed in XML