Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XMLDOM navigation
Message
From
18/10/2007 09:46:50
Mike Sue-Ping
Cambridge, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01261586
Message ID:
01261827
Views:
13
Hi Yuri,

Thanks for the reply. Your code doesn't really do what I need (unless I'm not understanding it).

I'd like to know when I've reached the "RegionID" level of the hierarchy in a generic way, i.e. not actually checking .nodename="RegionID". I was hoping that the RegionID node would have a .hasChildNodes=.F. but of course it is .T. since Name is a node of RegionID.

I suppose I'm going to have to iterate thru the hierarchy to see how deep it goes then step back out two levels.

Regards,

Mike

>Something like this:
>
>
>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
>*------------------------------
>
Previous
Reply
Map
View

Click here to load this message in the networking platform