Solved

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

Posted on 2003-11-11
3
395 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
Comment Utility
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
Comment Utility
GRRRRRRR
Its always something small. Thanks Mike I just failed to spot that.
0
 
LVL 26

Expert Comment

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

Regards,
Mike Sharp
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now