Sort MSXML2.DomDocument

I am wondering if an XMLDOM result can be sorted before it is iterated through. My code looks like this, but before iterate and display certain nodes, I want to sort the quantity.

Dim GetRequest
GetRequest = "

Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
    httpReq.Open "GET",GetRequest, False
         Set myXmlDoc =Server.CreateObject("MSXML2.DOMDocument")
    Set httpReq = Nothing
      'Get the necessary nodes to run the calculations.
      Set objNodeList = myXmlDoc.getElementsByTagName("Quantity")
      Set objNodeList2 = myXmlDoc.getElementsByTagName("CountryName")
            'Cycle through nodes and do calculations.
            QtyCount = 0
            For i = 0 TO (objNodeList.length -1)
              Set objNode = objNodeList.nextNode
              Set objNode2 = objNodeList2.nextNode
            Quantity = objNode.text
             Country = objNode2.text
            'If DupQtyRemove = Quantity OR Country = "China" Then      
                        Response.Write(Quantity & " " & Country & "<br />")
                        QtyCount = Quantity + QtyCount
                  End if
            DupQtyRemove = Quantity
Who is Participating?
You could load the XML data into a disconnected recordset, then use the recordset sort function to do what you need.
I also found this:

Sorry for posting links, XML isn't my strongest discipline.
That last link is for ChiliKat. Not sure if that's applicable to you.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

tarrigoAuthor Commented:
These are good solutions that I might try. Chilkat is a great product, but it does not handle all XML results. I have contacted them numerous times about it and they pretty much gave up on trying to modify their product. It does not handle diffgram or Dataset being in the XML result set on a HTTP GET. Otherwise I would have great things to say about the product.

They accused me of not installing it, but I showed them many times that if I commented those lines out that the XML file iterated great using their component.

Anyways, I decided to go with the MSXMLDOM and it is crucial I sort the result because I have to iterate through the result and make sure that any duplicate quanitities do not get added twice. We query an electronic parts database and through a web service and duplicate quantities tend to mean it is the same part trying to be sold by multiple brokers.

It sounds like a disconnected recordset would work great for you then.
Also, and keep in mind, I'm not the XML expert, but you can use an XSL document to consume the XML and produce your desired results.
I'm just old fashioned though, I'd use the recordset :)
Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.