CollectionNode - cXMLDOMNodeList

Accesses items of a collection by item number

Type: Function

Return Data Type: Handle

Parameters: Integer I

IThe item number

Return Value

Should return a valid DataFlex object. Remove the object using the Destroy message when it is no longer needed.

Function CollectionNode Integer I Returns Handle

Call: Get CollectionNode I to HandleVariable


CollectionNode is used to access items of a collection by item number I.


For iItem From 0 To iItems
    Get CollectionNode Of hoList iItem to hoNode

Parsing an XML Document within a BPO

This sample shows you how to access an XML Document. To access an XML document for editing or reporting purposes you do the following:

The translates into DataFlex code as follows:

Object oBPOXML is a BusinessProcess
    Procedure OnProcess
        Handle hoXML hoRoot hoList hoCust
        Integer iItems i bOK

        Get Create U_cXMLDOMDocument to hoXML
        // you can use Create (as above) or create
        // the object using standard Object syntax (as below) 
        //    Object oXML is a cXmlDomDocument
        //       Move Self to hoXML
        //    End_Object

        Set psDocumentName of hoXML to "http://localhost/xml/customer.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
        Showln 'loaded'
        Get DocumentElement of hoXML to hoRoot
        Get FindNodeList of hoRoot "CUSTOMER" to hoList
        Get NodeListLength of hoList to iItems
        Decrement iItems
        For i from 0 to iItems
            Get CollectionNode of hoList i to hoCust
            Send ShowCust hoCust

            Send Destroy of hoCust
        Send Destroy of hoList
        Send Destroy of hoXML

    Procedure ShowCust Handle hoCust
        String sName sPhone sState
        Get AttributeValue of hoCust "NAME" to sName
        Get ChildNodeValue of hoCust "TELEPHONE" to sPhone
        Get ChildNodeValue of hoCust "ADDRESS/STATE" to sState
        Showln sName ' ' sPhone ' ' sState


See Also

FindNodeList | NodeListLength