sort with vbscript, selectSingleNode query sort xml - XML SOAP

This is a discussion on sort with vbscript, selectSingleNode query sort xml - XML SOAP ; Hi all, I'm using the following xslt to extract the first node from a set. I am using a sort to get the correct one. <xsl:for-each select="//*[@urlName='11']/node"> <xsl:sort select="@sortOrder" data-type="number" order="ascending"/> I almost get the same result with the following ...

+ Reply to Thread
Results 1 to 5 of 5

sort with vbscript, selectSingleNode query sort xml

  1. Default sort with vbscript, selectSingleNode query sort xml

    Hi all,

    I'm using the following xslt to extract the first node from a set. I am
    using a sort to get the correct one.

    <xsl:for-each select="//*[@urlName='11']/node">
    <xsl:sort select="@sortOrder" data-type="number" order="ascending"/>


    I almost get the same result with the following vbscript line but have been
    unable to get the sort bit in there.

    Set Node = xmlDoc.selectSingleNode("//*[@urlName='11']/node")


    I would like everything to be in vbscript for the time instead of loading
    the xslt and using that, there must be a way to add the sort to the query.
    I tried:

    Set Node = xmlDoc.selectSingleNode("//*[@urlName='" & incoming &
    "']/node[last()]")


    But that gives me the wrong results.

    Here's a simplified version of the xml:
    <root>
    <node urlName="11">
    <node urlName="asd" sortOrder="3"></node>
    <node urlName="qwe" sortOrder="1"></node>
    <node urlName="zxc" sortOrder="2"></node>
    </node>
    </root>


    Anyone out there has the answer?



  2. Default Re: sort with vbscript, selectSingleNode query sort xml



    Marc wrote:


    > I'm using the following xslt to extract the first node from a set. I am
    > using a sort to get the correct one.
    >
    > <xsl:for-each select="//*[@urlName='11']/node">
    > <xsl:sort select="@sortOrder" data-type="number" order="ascending"/>
    >
    >
    > I almost get the same result with the following vbscript line but have been
    > unable to get the sort bit in there.
    >
    > Set Node = xmlDoc.selectSingleNode("//*[@urlName='11']/node")


    Well xsl:sort is part of the XSLT language to make transformation, if
    you use selectSingleNode on an MSXML document or node then you are
    restricted to XPath and XPath has no features to sort.
    The XPath functions you can use with MSXML are documented here
    <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/b5c850f1-077d-4200-81eb-f723436d65ae.asp>

    If you need to sort/restructure the original document then with MSXML I
    don't think you can avoid using XSLT, XPath alone does not do that.


    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

  3. Default Re: sort with vbscript, selectSingleNode query sort xml


    "Martin Honnen" <mahotrash@yahoo.de> wrote in message
    news:%230DIs4Z1GHA.4632@TK2MSFTNGP03.phx.gbl...
    >
    >
    > Marc wrote:
    >
    >
    >> I'm using the following xslt to extract the first node from a set. I am
    >> using a sort to get the correct one.
    >>
    >> <xsl:for-each select="//*[@urlName='11']/node">
    >> <xsl:sort select="@sortOrder" data-type="number" order="ascending"/>
    >>
    >>
    >> I almost get the same result with the following vbscript line but have
    >> been unable to get the sort bit in there.
    >>
    >> Set Node = xmlDoc.selectSingleNode("//*[@urlName='11']/node")

    >
    > Well xsl:sort is part of the XSLT language to make transformation, if you
    > use selectSingleNode on an MSXML document or node then you are restricted
    > to XPath and XPath has no features to sort.
    > The XPath functions you can use with MSXML are documented here
    > <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/b5c850f1-077d-4200-81eb-f723436d65ae.asp>
    >
    > If you need to sort/restructure the original document then with MSXML I
    > don't think you can avoid using XSLT, XPath alone does not do that.
    >
    >
    > --
    >
    > Martin Honnen --- MVP XML
    > http://JavaScript.FAQTs.com/


    Hi Martin,

    Well... I was afraid the answer would be like that, thanks for the link and
    your quick reply, I guess I need to use the xslt then.

    Kind regards,

    Marc



  4. Default Re: sort with vbscript, selectSingleNode query sort xml

    You could always try doing your select in code, stuffing the results into an array, sort the array, and then process each item in the array after they've been sorted.

    --
    Greg Collins [Microsoft MVP]
    Visit Brain Trove ( http://www.BrainTrove.com )



  5. Default Re: sort with vbscript, selectSingleNode query sort xml


    "Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_com> wrote in message
    news:ugN%23G5d1GHA.4924@TK2MSFTNGP05.phx.gbl...
    You could always try doing your select in code, stuffing the results into an
    array, sort the array, and then process each item in the array after they've
    been sorted.

    --
    Greg Collins [Microsoft MVP]
    Visit Brain Trove ( http://www.BrainTrove.com )

    Oh... now there's an idea...



+ Reply to Thread

Similar Threads

  1. Replies: 6
    Last Post: 09-10-2007, 06:10 AM
  2. Re: [B,IX] = sort(A,...) - Order for sort()-function
    By Application Development in forum Python
    Replies: 0
    Last Post: 05-29-2007, 10:34 AM
  3. automatic bubble sort into quick sort?
    By Application Development in forum Theory
    Replies: 6
    Last Post: 03-18-2007, 10:34 AM
  4. Query on DataView.Sort Property
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 10-22-2003, 06:01 PM
  5. Replies: 0
    Last Post: 09-09-2003, 02:11 AM