# XML Iter with XPath using node() fails on xml comments

**URL:** https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145
**Category:** Bugs
**Created:** [August 31, 2009, 8:21am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145 "2009-08-31T08:21:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nelsonwolf](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@nelsonwolf](https://www.finalbuilder.com/forums/u/nelsonwolf)
#### Post date: [August 31, 2009, 8:21am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/1 "2009-08-31T08:21:14Z")

</div>

I'm using an XML&nbsp;Iterator and if there are XML&nbsp;comments at the same level as the nodes I'm selecting it fails with the following message:

&nbsp;

Loading XML file J:\my.xml

Evaluating XPath & selecting XML nodes...

Found 17 Nodes

The iterator could not be initialised.

Invalid node type (8), please check your XPath

The value of the node selected is: &nbsp;blah&nbsp;

&nbsp;

Example XPath:&nbsp;/Build/node()

XML&nbsp;Comment:&nbsp;&lt;Build&gt;&lt;!--&nbsp;This is a comment that blo --&gt;&lt;GoodNode /&gt;&lt;/Build&gt;

&nbsp;

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [August 31, 2009, 11:45am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/2 "2009-08-31T11:45:00Z")

</div>

Hi Nelson   
  
 Paul and I fixed this one late yesterday, the code that generates the xpath to a node was not dealing with comment nodes correctly. This build has the fix :   
  
 [https://www.finalbuilder.com/downloads/finalbuilder/630/FB630\_1684.exe](https://www.finalbuilder.com/downloads/finalbuilder/630/FB630_1684.exe)

---

<div class="post-metadata">

### Author: ![nelsonwolf](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@nelsonwolf](https://www.finalbuilder.com/forums/u/nelsonwolf)
#### Post date: [September 9, 2009, 12:55pm UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/3 "2009-09-09T12:55:17Z")

</div>

&nbsp;Hi Vincent,

I tried 6.3.1684 but the bug is still happening. &nbsp;Attaching example.

-Nelson

I&nbsp;think a different error though:

Action Messages:  
Error updating iterator status after iteration #2 :   
Error Setting Variable: Interface not supported  
&nbsp;

[002\_001\_XMLIterCommentBug.zip](https://www.finalbuilder.com/forums/uploads/default/original/2X/a/aa0ef6fe12c54d2581f8b2565e6df2eb3ffd57c0.zip) (23.589 KB)

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 9, 2009, 8:45am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/4 "2009-09-09T08:45:51Z")

</div>

Hi Nelson   
  
 This was the same error with a different cause. We were assuming that the nodes selected by xpath would only be elements, but using the node() function also selects comments (not sure if that’s what you intended or not). I spent this afternoon reworking the code that generates the xpath for a given node. The old version was not reliable with some node types (didn’t handle comments or attribute nodes properly and could generate invalid xpath). The new version is I believe much more reliable. I tested with a bunch of different xml documents with and without namspaces and various xpath statements and it seems a lot more robust.   
  
 [https://www.finalbuilder.com/downloads/finalbuilder/630/FB630\_1706.exe](https://www.finalbuilder.com/downloads/finalbuilder/630/FB630_1706.exe)   
  
 We are hoping to release an official update tomorrow so please let us know asap if this build is not working as expected. I will continue testing here, however there are an infinite number of xpath/xml combination’s so it’s still possible I’ve missed something.

---

<div class="post-metadata">

### Author: ![nelsonwolf](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@nelsonwolf](https://www.finalbuilder.com/forums/u/nelsonwolf)
#### Post date: [September 9, 2009, 10:16am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/5 "2009-09-09T10:16:18Z")

</div>

Hi Vincent,   
  
 I did not need to actually select the comments. I tested the build and it fixes the comment issue, but the behavior of the iterator has changed a little. Previously the iterator would return a non indexed XPath if there was only node being returned. Now the returned XPath is always indexed. Also I see comment() nodes are being returned now. I don’t think this effects our older scripts, but my new stuff expects different values. I am rewriting it now to support the new build.   
  
 One strange effect of upgrading is my tool paths have been changed.   
  
 SVN Path went from: C:\Program Files\CollabNet Subversion Client to C:\Program Files\CollabNet Subversion   
  
 VVS2005 seems to be have changed to C:\Program Files\Microsoft Visual Studio 9.0 when before it was set to C:\Program Files\Microsoft Visual Studio 8\Common7\IDE.   
  
 -Nelson

---

<div class="post-metadata">

### Author: ![nelsonwolf](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@nelsonwolf](https://www.finalbuilder.com/forums/u/nelsonwolf)
#### Post date: [September 9, 2009, 10:26am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/6 "2009-09-09T10:26:23Z")

</div>

FYI I believe I finished updating my scripts so it appears they now work correctly with the new XML Iterator return values.

---

<div class="post-metadata">

### Author: ![nelsonwolf](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/b9e5f3/32.png) [@nelsonwolf](https://www.finalbuilder.com/forums/u/nelsonwolf)
#### Post date: [September 10, 2009, 1:54am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/7 "2009-09-10T01:54:37Z")

</div>

Also just upgraded another machine and that didn't seem to change the tool paths. Maybe that's a non-issue.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 14, 2009, 8:13am UTC](https://www.finalbuilder.com/forums/t/xml-iter-with-xpath-using-node-fails-on-xml-comments/3145/8 "2009-10-14T08:13:34Z")

</div>

Hi There!  
&nbsp; This is Jannsenn!  
Im new in this site!  
&nbsp;&nbsp; I hope I can have more friends here and I can ans. anyone for there question or prob..  
&nbsp;&nbsp;&nbsp;&nbsp; The new version is I believe much more reliable. I tested with a bunch of different xml documents with and without namspaces and various xpath statements and it seems a lot more robust.  
&nbsp;&nbsp;&nbsp; Keep on posting Guys!  
&nbsp; Thanks!...  
Have a nice Day!.....  
&nbsp;
