Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-11
3
Medium Priority
?
407 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 800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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