//------------------------------------------------------->
// Goal is to fix numbering in service.po_number
//------------------------------------------------------->
Use Windows
Use MsgBox
Use DLL
Use vWin32fh.pkg
Use cApplication.pkg

#REPLACE CURRENT$WORKSPACE   "dbImport"

Integer iFile iLastIndex
Integer iAns
Integer giCounter
Move 0 to giCounter

Object oApplication is a cApplication
    Procedure OnCreate
        Send DoOpenWorkspace CURRENT$WORKSPACE
    End_Procedure
End_Object  // oApplication

Use flexml.pkg

    Procedure Add_Ids
        Handle hoXML hoRoot hoList hoCust hoCol hoAttributeNode hoAttributeCollection
        Integer iItems i bOK iAttributeCount
        String sName sAttributeValue

        Get Create U_cXMLDOMDocument to hoXML

        Set psDocumentName of hoXML to "D:\VDF12.0\Projects\dbImport\Data\CODETYPEOutput3.Xml"
        Set pbAsync of hoXML to False
        Set pbValidateOnParse of hoXML to True

        Get LoadXMLDocument of hoXML to bOK

        If not bOK Begin
            Send BasicParseErrorReport of hoXml
            Procedure_Return
        End
        Showln 'loaded'
        Get DocumentElement of hoXML to hoRoot
        Get FindNodeList of hoRoot "Row" to hoList
        Get NodeListLength of hoList to iItems
showln "items " iItems
        Decrement iItems
//        For i from 0 to iItems
//showln "i " i
//            Get CollectionNode of hoList i to hoCust

////            Get FindNode of hoCust "Type" To hoCol
//Get AttributeValue of hoCust "TYPE" to sName


////            Get ChildNodeValue of hoCust "Type" to sName
//            showln "value: " sName
//            Send Destroy of hoCust
//        Loop


        Get AttributeNodes of hoNode to hoAttributeCollection

        // Show the attributes of the collection.
        // First, get the number of items in the set
        Get NodeListLength of hoAttributeCollection to iAttributeCount
        // Now, iterate through the list of items.
        For i From 0 to (iAttributeCount-1)
            // Get each attribute (indexed by i) -
            // a dynamic object is returned.
            Get CollectionNode of hoAttributeCollection i to hoAttributeNode
            // Get the name of the attribute.
            Get psNodeName of hoAttributeNode to sAttributeName
            // Get its value.
            Get psText of hoAttributeNode to sAttributeValue
            // Show on the screen.
            Showln "Attribute " sAttributeName " has the value "  sAttributeValue
            // Destroy the attribute object.
            Send Destroy of hoAttributeNode
        Loop
        Send Destroy of hoAttributeCollection

        Send Destroy of hoList
        Send Destroy of hoXML

    End_Procedure


Showln "Starting "
Send Add_IDS

Showln "Ending "
Sleep 2