Solved

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

Posted on 2003-11-11
3
397 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c# & linq 7 87
SVG, D3, scaling, translation 11 141
SharePoint 2013 Blog Template 2 36
Get the parent node - XMLTYPE 9 56
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…
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

16 Experts available now in Live!

Get 1:1 Help Now