Solved

XPATH problem moving to next Node of XPATH Parent (../)

Posted on 2003-11-11
3
401 Views
Last Modified: 2012-05-04
The problem I have is that the asp code will work on the first loop  but throws up an error when it tries to move to next node. The problem seems to be set oNode = oNode.nextNode. is this the right function of should another be used when looping through parent nodes of XPATH Query.

 
I should be able to get:
1516---first loop
1517--second loop

XML FIle:

<MASTERSMSLIST>
      <MSISDN VALUE="1515">
            <LIST NAME="gang" COM="dfba" ORG="dfgaa"/>
            <LIST NAME="centre" COM="dfba" ORG="dfgaa"/>
      </MSISDN>
      <MSISDN VALUE="1516">
            <LIST NAME="centre" COM="dfba"/>
            <LIST NAME="exec" COM="dfba"/>
      </MSISDN>
      <MSISDN VALUE="1517">
            <LIST NAME="exec" COM="dfba"/>
      </MSISDN>
</MASTERSMSLIST>

ASP
'Unnecessary code removed

      sXPATH =      "//MSISDN[@VALUE]/LIST[@NAME='exec'][@COM='dfba']/.."
                 
                Set oNode = oListXML.SelectNodes(sXPATH)

            If oNode.length > 0 then
                      For i = 1 To oNode.length
                             set oNode = oNode.nextNode
                        'Problem seems to be with this

                               sData = oNode.getAttribute("VALUE")
                               'Do Stuff with No
                  next
            end if


0
Comment
Question by:edcal
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 200 total points
ID: 9728391
oNode starts out as a nodelist object.  If you then set oNode to a single node, the nextNode() method will throw an exception as this doesn't exist in the IXMLDOMNode interface.

I prefer a notation that keeps you from making mistakes like this, where nodelists are represented by something like

              Set oNodeList = oListXML.SelectNodes(sXPATH)

Here's a loop on a nodelist in Javascript:

for (var i=0; i<oNodeList.length; i++) {
  oNode = oNodeList.nextNode();
  alert(oNode .text);
}

In VBScript, it might be something like:

For i = 1 to oNodeList.length
  set oNode = oNodeList.nextNode
Next


Regards,
Mike Sharp
0
 
LVL 2

Author Comment

by:edcal
ID: 9730421
GRRRRRRR
Its always something small. Thanks Mike I just failed to spot that.
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 9732721
Ah yes, the truly enormous errors are usually obvious!  ;^)

Regards,
Mike Sharp
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question