Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2004

Tip: Looking for answers? Try searching our database.

traversing xmlnode a 2nd time fails...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RickH - 11 Aug 2004 03:15 GMT
Dim xmlNodeListA, xmlNodeListB AS IXMLDOMNodeList
xmlNodeListA = thisDocument.DOM.selectNodes
("/dfs:myfields/dfs:dataFields/d:Offloaf_Request")

For Each xmlNodeA In xmlNodeListA
    xmlNodeListB = xmlNodeA.childNodes

    For Each xmlNodeB in xmlNodeListB

        'read data--- works fine
    Next
    'Do calculations from read data in all xmlNodeListB
    'Walk thru xmlNodeListB again to write data
    For Each xmlNodeB in xmlNodeListB

        'write data   ---fails, says no instance of object
    Next
Next

I can't seem to find the correct syntax for walkung thru the node a second
time..any ideas??
Tried everything I could think of..
RickH - 11 Aug 2004 04:03 GMT
Putting xmlNodeListB.reset before I run thru the 2nd time is supposed to set
the pointer back to the beginning, but it doesn't seem to...
Greg Collins [MVP] - 11 Aug 2004 04:25 GMT
You should be using: (Sorry this is JScript and not VB, but it works in VB too when translated):

var oNodes = XDocument.DOM.selectNodes("{XPath}");
var oNode = null;
while(oNode = oNodes.nextNode())
{
   // Process current node here.
}

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

Dim xmlNodeListA, xmlNodeListB AS IXMLDOMNodeList
xmlNodeListA = thisDocument.DOM.selectNodes
("/dfs:myfields/dfs:dataFields/d:Offloaf_Request")

For Each xmlNodeA In xmlNodeListA
xmlNodeListB = xmlNodeA.childNodes

For Each xmlNodeB in xmlNodeListB

'read data--- works fine
Next
'Do calculations from read data in all xmlNodeListB
'Walk thru xmlNodeListB again to write data
For Each xmlNodeB in xmlNodeListB

'write data   ---fails, says no instance of object
Next
Next

I can't seem to find the correct syntax for walkung thru the node a second
time..any ideas??
Tried everything I could think of..
RickH - 11 Aug 2004 06:59 GMT
I'll try the While....construct.
I did get it to work by using for i to n..Next construct.
Appears the For Each ..Next would not let me rewalk the same node--.reset
didn't do anything..
RickH - 11 Aug 2004 21:07 GMT
this syntax worked for VB
xmlNodeListA = thisXDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/*")
  xmlNodeA = Nothing    
  xmlNodeA = xmlNodeListA.nextNode()
     While Not xmlNodeA Is Nothing

    'do stuff

    xmlNodeA = xmlNodeListA.nextNode()
     End While
Greg Collins [MVP] - 13 Aug 2004 03:13 GMT
Can the while loop be simplified? for example:

While Not(xmlNodeA = xmlNodeListA.nextNode() Is Nothing)

' do stuff

End While

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

this syntax worked for VB
xmlNodeListA = thisXDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/*")
  xmlNodeA = Nothing    
  xmlNodeA = xmlNodeListA.nextNode()
     While Not xmlNodeA Is Nothing

'do stuff

xmlNodeA = xmlNodeListA.nextNode()
     End While
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.