473,287 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Logic and Syntax for Node Iteration

Hello;

I have the below XML schema which I'm trying to iterate through node by
node. The script I'm using is also shown below. The resulting output,
also shown below, shows that I'm not reaching the element "tblTestCase"
nor the attribute names "TeamID" and "ProdID". How should I change my
script to make it follow the nodes all the way through?

Thanks,
Gregg

Please note that I've modified the XML for brevity and also so that it
isn't read as xml code by the post.

xsd:schema
targetNamespace="http://schemas.microsoft.com/office/infopath/2003/ado/d
ataFields" elementFormDefault="unqualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataField
s"
xsd:element name="tblTestCase"
xsd:complexType
xsd:attribute name="TeamID" use="optional"
xsd:simpleType
xsd:restriction base="xsd:string"
xsd:maxLength value="10"/
/xsd:restriction
/xsd:simpleType
/xsd:attribute
xsd:attribute name="ProdID" use="optional"
xsd:simpleType
xsd:restriction base="xsd:string"
xsd:maxLength value="10"/
/xsd:restriction
/xsd:simpleType
/xsd:attribute

OUTPUT FILE:
NodeName NodeType
++++++++ ++++++++++
mso-application progid="InfoPath.Document" 7
dfs:myFields 1
dfs:queryFields 1
dfs:queryFields 1
#text 3
dfs:dataFields 1
#text 3
my:FileAttachment 1
#text 3
my:PassFail 1
#text 3
Expand|Select|Wrap|Line Numbers
  1. set oNodeList = root.childnodes
  2. MoreNodes = True
  3. Do While MoreNodes
  4. i = 0
  5. Display_NodeList oNodeList, i, MoreNodes
  6.  
  7. Loop
  8.  
  9. Sub Display_NodeList(varNodeList, varIndex, boolMoreNodes)
  10. boolMoreNodes = False
  11. For Each Item In varNodeList
  12. varIndex = varIndex + 1
  13. if varIndex < varNodeList.length then
  14. strTextLine=varNodeList.item(varIndex).nodename & " " &
  15. varNodeList.item(varIndex).nodevalue & " " &
  16. varNodeList.item(varIndex).nodetype
  17. write_lines strTextLine
  18. 'msgbox "Listing the EXISTING nodes"
  19. 'MsgBox varNodeList.item(varIndex).nodename & " " &
  20. varNodeList.item(varIndex).nodevalue & " " &
  21. varNodeList.item(varIndex).nodetype
  22. If varNodeList.item(varIndex).hasChildNodes() then
  23. boolMoreNodes = True
  24. MsgBox varNodeList.item(varIndex).nodename & "has child
  25. nodes"
  26. IF varNodeList.length = 9 then
  27. do while i3 < 9
  28. i3 = i3 + 1
  29. strTextLine=varNodeList.item(i3).nodename & " " &
  30. varNodeList.item(i3).nodevalue & " " & varNodeList.item(i3).nodetype
  31. write_lines strTextLine
  32. loop
  33. 'msgbox varNodeList.item(1).nodename
  34. 'msgbox varNodeList.item(2).nodename
  35. 'msgbox varNodeList.item(3).nodename
  36. 'msgbox varNodeList.item(4).nodename
  37. 'msgbox varNodeList.item(5).nodename
  38. 'msgbox varNodeList.item(6).nodename
  39. 'msgbox varNodeList.item(7).nodename
  40. 'msgbox varNodeList.item(8).nodename
  41. 'msgbox varNodeList.item(9).nodename
  42. end if
  43. 'set oNodeList2 =
  44. root.getelementsbytagname(oNodeList.item(i).nodename)
  45. set varNodeList = varNodeList.item(varIndex).childnodes
  46. varIndex=0
  47. 'set oNodeList2 =
  48. oNodeList.selectnodes(oNodeList.item(i).nodename)
  49. 'set oNodeList2 =
  50. root.selectnodes(oNodeList.item(i).nodename)
  51. end if
  52. if varNodeList.item(varIndex).nodeType = 3 then
  53. MsgBox "TEXT NODE: " & varNodeList.item(varIndex).nodename &
  54. " " & varNodeList.item(varIndex).nodevalue & " " &
  55. varNodeList.item(varIndex).nodetype
  56. MSGBOX varNodeList.item(varIndex).text
  57. end if
  58. if varNodeList.item(varIndex).nodeType = 4 then
  59. MsgBox "ATTR NODE: " & varNodeList.item(varIndex).nodename &
  60. " " & varNodeList.item(varIndex).nodevalue & " " &
  61. varNodeList.item(varIndex).nodetype
  62. MSGBOX varNodeList.item(varIndex).text
  63. end if
  64. end if
  65. Next
  66.  
  67. end sub
  68.  
*** Sent via Developersdex http://www.developersdex.com ***
Jun 9 '07 #1
0 1795

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xenophobe | last post by:
I'm having a brain freeze on how to go about creating the logic for evenly distributing a group of items in rotation through multiple iterations. I'm particularly looking for logic flow help and...
5
by: Robin Becker | last post by:
This function from texlib in oedipus.sf.net is a real cpu hog and I determined to see if it could be optimized. def add_active_node(self, active_nodes, node): """Add a node to the active node...
1
by: Martin Danielson | last post by:
I have a problem that I can't work out. I have a script in ASP using VBScript that act quite funny when editing and xml file. Here is my explenation I have the following xml-fil <root><element...
1
by: lallous | last post by:
Hello I'm new to C# language and wonder if the code is correct syntax wise but not necessarily logic wise. private void nodeMoveUp(TreeView tv) { TreeNode tn = tv.SelectedNode; if (tn ==...
0
by: rishf1 | last post by:
My code is building a DirectoryEntry and its siblings to match the configuration set out in the xml file with the following structure: <ou name="newDomain" schema="organizationalUnit"> <ou...
1
by: PaulF | last post by:
I am trying to do add a repeating XmlNode into and existing XML document and have had some problems. The base XML: <Property> <Premises> <Endorsement> <ShortWording/> <Wording/>
9
by: anunaygupta | last post by:
Hello all, I have a data structures problem. Assume there are 2 linked lists L1 and L2. They merge into some node. L1 1->2->3->4->5->6 / L2 8->7->9->/ L1 and L2 merge in node with value...
37
by: at | last post by:
I would like to spark the discussion about the following syntax problem I encounter. THE PROBLEM I have a lot times the following code: for x in : if x 0: ... more code...
0
by: subramanian100in | last post by:
I have given below the structures and the function that finds the height of a BST by iteration. I have tested the function for several input sets and it is working. Kindly review the code and...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.