This example reads hierarchical data
The input to this example is the following XML file:
<Earch> <Europe> <England lan="E"> </England> <Switzerland lan="F/I/D"> <Geneva lan="F"> <Geneva/> <Meyrin/> <Versoix/> </Geneva> <Bern lan="D"> <Bern/> </Bern> <Valais lan="F/D"> <Sion lan="F"/> <Martigny lan="F"/> </Valais> </Switzerland> </Europe> <America> <Usa lan="E"> <New-York/> <Florida> </Florida> </Usa> <Brazil lan="P"> </Brazil> <Argentina lan="E"/> </America> </Earch>
The code in the example calls the 'fwXml_childNodesContent()' function more than once:
rtn_code = fwXml_childNodesContent ( xml_doc_ident , top_elem_ident , node_names , attributes , nodevalues , exInfo );
One checks the return-code against what one expects, namely that it contains simple element nodes as well as complex element nodes. In other words, the element node in turn contain more than one child or not a text-node.
if ( fwXml_containsNodeTypes ( rtn_code , ( fwXml_CONTAINS_SIMPLE_ELEMENT_NODES | fwXml_CONTAINS_COMPLEX_ELEMENT_NODES ) ) )
The following is returned via the three output-parameters:
The program then prints out the returned information in the three dynamic variables in the following form:
WCCOAui1:["document = 0"] WCCOAui1:["1-child = 0"] WCCOAui1:["topelem = [0] 'Earch'"] WCCOAui1:["rtn_code = 2"] WCCOAui1:["TagName = [1] 'Europe'"] WCCOAui1:["rtn_code = 2"] WCCOAui1:["TagName = [2] 'England' Attribs 'lan:E'"] WCCOAui1:["TagName = [2] 'Switzerland' Attribs 'lan:F/I/D'"] WCCOAui1:["rtn_code = 2"] WCCOAui1:["TagName = [3] 'Geneva' Attribs 'lan:F'"] WCCOAui1:["rtn_code = 0"] WCCOAui1:["TagName = [4] 'Geneva'"] WCCOAui1:["TagName = [4] 'Meyrin'"] WCCOAui1:["TagName = [4] 'Versoix'"] WCCOAui1:["TagName = [3] 'Bern' Attribs 'lan:D'"] WCCOAui1:["rtn_code = 0"] WCCOAui1:["TagName = [4] 'Bern'"] WCCOAui1:["TagName = [3] 'Valais' Attribs 'lan:F/D'"] WCCOAui1:["rtn_code = 0"] WCCOAui1:["TagName = [4] 'Sion' Attribs 'lan:F'"] WCCOAui1:["TagName = [4] 'Martigny' Attribs 'lan:F'"] WCCOAui1:["TagName = [1] 'America'"] WCCOAui1:["rtn_code = 2"] WCCOAui1:["TagName = [2] 'Usa' Attribs 'lan:E'"] WCCOAui1:["rtn_code = 0"] WCCOAui1:["TagName = [3] 'New-York'"] WCCOAui1:["TagName = [3] 'Florida'"] WCCOAui1:["TagName = [2] 'Brazil' Attribs 'lan:P'"] WCCOAui1:["TagName = [2] 'Argentina' Attribs 'lan:E'"] WCCOAui1:["rtn_code = 0"]