Solved

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

Posted on 2003-11-11
3
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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