This example returns all 'room' Element-Nodes that are inside 'bedrooms' Tag-Names
The input to this example is the following XML file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE home []> <home colour="white" floors="2"> <infos>This is my house</infos> <floor level="0"> <room type="other">Entry-hall</room> <room type="kitchen" ground="stone"/> <room type="living" ground="parquet">Table<sep/>Sofa<sep/>TV</room> </floor> <floor level="1"> <room type="other">Bathroom</room> <bedrooms count="3" colour="creme"> <room use="parents" beds="1"/> <room use="kids" beds="3"/> <room use="spare" colour="pine">Computer<sep/>Play-ground</room> </bedrooms> </floor> </home>
The code in the example calls several times the 'fwXml_elementsByTagName()' function. First to find the list of 'bedrooms' tag-nodes, then to find all 'room' tag-nodes inside each of the 'bedrooms':
elements = fwXml_elementsByTagName ( docum , -1 , "bedrooms" , exInfo ); for ( int idx = 1 ; idx <= dynlen(elements) ; ++idx ) { children = fwXml_elementsByTagName ( docum , elements[idx] , "room" , exInfo ); }
The program then prints out the hierarchical list of rooms inside each bedroom:
WCCOAui1:["document = 0"] WCCOAui1:["TagName of Node 16 = 'bedrooms' Attribs = 'colour:creme | count:3'"] WCCOAui1:[""] WCCOAui1:["TagName of Node 25 = 'room' Attribs = 'beds:1 | use:parents'"] WCCOAui1:["TagName of Node 26 = 'room' Attribs = 'beds:3 | use:kids'"] WCCOAui1:["TagName of Node 27 = 'room' Attribs = 'colour:pine | use:spare'"] WCCOAui1:[""] WCCOAui1:["rtn_code = 0"]