Logic and Syntax for Node Iteration

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gregg

    #1

    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 "tblTestCas e"
    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.microso ft.com/office/infopath/2003/ado/d
    ataFields" elementFormDefa ult="unqualifie d"
    attributeFormDe fault="unqualif ied"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:d="http://schemas.microso ft.com/office/infopath/2003/ado/dataField
    s"
    xsd:element name="tblTestCa se"
    xsd:complexType
    xsd:attribute name="TeamID" use="optional"
    xsd:simpleType
    xsd:restriction base="xsd:strin g"
    xsd:maxLength value="10"/
    /xsd:restriction
    /xsd:simpleType
    /xsd:attribute
    xsd:attribute name="ProdID" use="optional"
    xsd:simpleType
    xsd:restriction base="xsd:strin g"
    xsd:maxLength value="10"/
    /xsd:restriction
    /xsd:simpleType
    /xsd:attribute

    OUTPUT FILE:
    NodeName NodeType
    ++++++++ ++++++++++
    mso-application progid="InfoPat h.Document" 7
    dfs:myFields 1
    dfs:queryFields 1
    dfs:queryFields 1
    #text 3
    dfs:dataFields 1
    #text 3
    my:FileAttachme nt 1
    #text 3
    my:PassFail 1
    #text 3


    Code:
    set oNodeList = root.childnodes
    MoreNodes = True
    Do While MoreNodes
    i = 0
    Display_NodeList oNodeList, i, MoreNodes
    
    Loop
    
    Sub Display_NodeList(varNodeList, varIndex, boolMoreNodes)
    boolMoreNodes = False
    For Each Item In varNodeList
    varIndex = varIndex + 1
    if varIndex < varNodeList.length then
    strTextLine=varNodeList.item(varIndex).nodename & " " &
    varNodeList.item(varIndex).nodevalue & " " &
    varNodeList.item(varIndex).nodetype
    write_lines strTextLine
    'msgbox "Listing the EXISTING nodes"
    'MsgBox varNodeList.item(varIndex).nodename & " " &
    varNodeList.item(varIndex).nodevalue & " " &
    varNodeList.item(varIndex).nodetype
    If varNodeList.item(varIndex).hasChildNodes() then
    boolMoreNodes = True
    MsgBox varNodeList.item(varIndex).nodename & "has child
    nodes"
    IF varNodeList.length = 9 then
    do while i3 < 9
    i3 = i3 + 1
    strTextLine=varNodeList.item(i3).nodename & " " &
    varNodeList.item(i3).nodevalue & " " & varNodeList.item(i3).nodetype
    write_lines strTextLine
    loop
    'msgbox varNodeList.item(1).nodename
    'msgbox varNodeList.item(2).nodename
    'msgbox varNodeList.item(3).nodename
    'msgbox varNodeList.item(4).nodename
    'msgbox varNodeList.item(5).nodename
    'msgbox varNodeList.item(6).nodename
    'msgbox varNodeList.item(7).nodename
    'msgbox varNodeList.item(8).nodename
    'msgbox varNodeList.item(9).nodename
    end if
    'set oNodeList2 =
    root.getelementsbytagname(oNodeList.item(i).nodename)
    set varNodeList = varNodeList.item(varIndex).childnodes
    varIndex=0
    'set oNodeList2 =
    oNodeList.selectnodes(oNodeList.item(i).nodename)
    'set oNodeList2 =
    root.selectnodes(oNodeList.item(i).nodename)
    end if
    if varNodeList.item(varIndex).nodeType = 3 then
    MsgBox "TEXT NODE: " & varNodeList.item(varIndex).nodename &
    " " & varNodeList.item(varIndex).nodevalue & " " &
    varNodeList.item(varIndex).nodetype
    MSGBOX varNodeList.item(varIndex).text
    end if
    if varNodeList.item(varIndex).nodeType = 4 then
    MsgBox "ATTR NODE: " & varNodeList.item(varIndex).nodename &
    " " & varNodeList.item(varIndex).nodevalue & " " &
    varNodeList.item(varIndex).nodetype
    MSGBOX varNodeList.item(varIndex).text
    end if
    end if
    Next
    
    end sub
    *** Sent via Developersdex http://www.developersdex.com ***
Working...