>CLEAR >CLOSE TABLES all >lclog="c:\log.txt" >ERASE (lclog) > >lcxml2read="c:\junk.xml" >iRead_TESTXML_File(lcxml2read) > >IF FILE(lclog) > MODIFY FILE (lclog) nowa >ENDIF >Return >*----------------------------------- >Procedure iRead_TESTXML_File >LPARAMETERS lcfile > >CLEAR >IF TYPE("lcfile")#"C" or NOT FILE(lcfile) > ?"Cannot find the file "+TRANSFORM(lcfile) > return >endif > >lnfp=fopen(fullpath(lcfile)) >if lnfp>0 > =fclose(lnfp) >ELSE > ?"Cannot open the file "+lcfile > return >endif > >oXML=CREATEOBJECT('msxml.domdocument') >oXML.LOAD(fullpath(lcfile)) >*?oxml.documentelement.childnodes.length > >isub=0 >DO iGetChild WITH oxml.documentelement,0 > >oXMl=.NULL. >release oXML >*---------------------------------- >PROCEDURE iGetChild >LPARAMETERS poChild,pSub >LOCAL oChild, oSubChild >PRIVATE isub >isub=psub >IF TYPE("poChild.childnodes")#"O" OR poChild.childnodes.Length <=0 > RETURN >ENDIF >WITH poChild > STRTOFILE(SPACE(4*isub)+.BaseName+", "+; > TRANSFORM(.childnodes.length)+; > IIF(isub>0 and .childnodes.length=1,", >"+.text+"<","")+; > CHR(13)+CHR(10), lclog,.t.) >endwith > >isub=isub+1 >*?ISNULL(poChild), poChild.BaseName, poChild.childnodes.length >FOR EACH oChild IN poChild.childnodes > WITH oChild > IF NOT EMPTY(.BaseName) OR .childnodes.length>0 > STRTOFILE(SPACE(4*isub)+.BaseName+", "+; > TRANSFORM(.childnodes.length)+; > IIF(.childnodes.length=1,", >"+.text+"<","")+; > CHR(13)+CHR(10),lclog,.t.) >*? SPACE(5),.BaseName, .childnodes.length, .Text > IF .childnodes.length>0 > FOR EACH oSubChild IN .childnodes > do iGetChild WITH oSubChild,isub+1 > endfor > ENDIF > endif > endwith >ENDFOR >Return >*------------------------------ >