Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 Tags
Subject: RE: xml and treeview
Thread ID: 298747 Message ID: 298790 # Views: 51 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Active X Controls & OLE Automation
Date: Friday, March 18, 2011 10:58:23 AM         
   


> But i have this configuration
> Starting from an XML file named test55output.xml (in the rar) below and want to populate a treview.
> your method dont work (forgetting the first cursor step).
> http://www.foxite.com/uploads/8cec9b00-d4b8-4523-940f-03e60b547472.rar
> Note i can rebuild a cursor from this photo and apply your method.
> how can i solution this,starting form the xml file only ?

I'll be busy for a few hours, so that, if nobody else jumps in with a solution, I'll look at your attachment later when I can access a PC having RAR abilities installed. (Or do you have a ZIP by chance?)
From what I understood so far, I believe we'll get it sorted anyway.


Regards, see you later
-Stefan






> > Salut Yousfi,
> >
> >
> > It's not the only one, but I'd say it's probably the easiest since tree views might work well with a "flat", denormalized data source anyway.
> > You can however also use the XMLAdapter class, or MS XML DOM (most powerful), or even generate "manually" via StrToFile (worst option IMO).
> >
> >
> > That might be no problem since XML actually has a kind of physical order (as opposed to the SQL concept).
> >
> >
> > If I gt your description right, it might boil down to use XMLToCursor for "reading" the input.XML, and CursorToXML for writing the output.XML, so I think the sample pasted below is not very extraordinary.
> >
> >
> > hth
> > -Stefan
> >
> >
> >
> >
> > * test data (normalized)
> > CREATE CURSOR continents (con_id I, con_name C(20))
> > INSERT INTO continents VALUES (1, 'Africa')
> > INSERT INTO continents VALUES (2, 'America')
> > INSERT INTO continents VALUES (3, 'Asia')
> > CREATE CURSOR countries (cou_id I, con_id I, cou_name C(20))
> > INSERT INTO countries VALUES (1, 1, 'Algeria')
> > INSERT INTO countries VALUES (2, 1, 'Egypt')
> > INSERT INTO countries VALUES (3, 2, 'Argentina')
> > INSERT INTO countries VALUES (4, 2, 'Brasil')
> > INSERT INTO countries VALUES (5, 3, 'China')
> > INSERT INTO countries VALUES (6, 3, 'India')
> > 
> > * treeview's data source: denormalized "flat file"
> > SELECT con_name, cou_name ;
> > 	FROM continents CO ;
> > 	JOIN countries CU ON CU.con_id = CO.con_id ;
> > 	INTO CURSOR crsTreeview
> > 
> > * treeview's actual data-source file is XML
> > CURSORTOXML('crsTreeview','test55input.xml',1,512)
> > 
> > * tree view
> > _screen.AddObject('tree','myTreeContainer')
> > _screen.tree.Visible = .T.
> > _screen.tree.SaveXML()
> > 
> > RETURN
> > 
> > 
> > 
> > DEFINE CLASS myTreeContainer as Container
> > 	BackStyle = 0
> > 	BorderWidth = 0
> > 	Width = 200
> > 	Height = 200
> > 	cTempCursor = SYS(2015)
> > 
> > 	PROCEDURE Init
> > 		LOCAL lnSelect
> > 		lnSelect = SELECT(0)
> > 		XMLTOCURSOR('test55input.xml',This.cTempCursor,512)
> > 
> > 		LOCAL loNode, lcContinent
> > 		lcContinent = ''
> > 		SCAN
> > 			IF !( con_name == m.lcContinent )
> > 				lcContinent = con_name
> > 				loNode = _screen.tree.oleTree.Nodes.Add(,1,m.lcContinent,con_name,0)
> > 				loNode.Expanded = .T.
> > 			ENDIF
> > 			loNode = _screen.tree.oleTree.Nodes.Add(m.lcContinent,4,SYS(2015),cou_name,0)
> > 		ENDSCAN
> > 
> > 		SELECT (m.lnSelect)
> > 	ENDPROC
> > 	PROCEDURE SaveXML
> > 		CURSORTOXML(This.cTempCursor,'test55output.xml',1,512)
> > 	ENDPROC
> > 
> > 	ADD OBJECT oleTree as oleControl WITH ;
> > 		OleClass = 'MSComctlLib.TreeCtrl.2', Width = 200, Height = 200
> > ENDDEFINE
> > 

>
> Bonjour Stefan et merci.
> this way you show : from cursor (mandatory)....>..xml..>..cursor..>..populate a tree.
> as you show its works well.
> But i have this configuration
> Starting from an XML file named test55output.xml (in the rar) below and want to populate a treview.
> your method dont work (forgetting the first cursor step).
> http://www.foxite.com/uploads/8cec9b00-d4b8-4523-940f-03e60b547472.rar
> Note i can rebuild a cursor from this photo and apply your method.
> this xml file represents a treeview like this photo:
>
> how can i solution this,starting form the xml file only ?
> thanks
>
> Regards
> Yousfi Benameur

COMPLETE THREAD

xml and treeview Posted by Yousfi Benameur @ 3/18/2011 1:29:49 AM
RE: xml and treeview Posted by Stefan Wuebbe @ 3/18/2011 8:46:56 AM
RE: xml and treeview Posted by Yousfi Benameur @ 3/18/2011 10:15:14 AM
RE: xml and treeview Posted by Stefan Wuebbe @ 3/18/2011 10:58:23 AM
RE: xml and treeview Posted by Yousfi Benameur @ 3/18/2011 11:36:32 AM
RE: xml and treeview Posted by Stefan Wuebbe @ 3/18/2011 6:55:26 PM
RE: xml and treeview Posted by Yousfi Benameur @ 3/18/2011 10:25:48 PM
RE: xml and treeview Posted by Stefan Wuebbe @ 3/19/2011 11:24:20 AM
RE: xml and treeview Posted by Yousfi Benameur @ 3/20/2011 12:08:32 AM
RE: xml and treeview Posted by Koen Piller @ 3/19/2011 12:49:26 PM
RE: xml and treeview Posted by Yousfi Benameur @ 3/19/2011 5:28:17 PM
RE: xml and treeview Posted by Koen Piller @ 3/19/2011 6:07:56 PM
RE: xml and treeview Posted by Bob Brook @ 3/18/2011 12:05:13 PM
RE: xml and treeview Posted by Yousfi Benameur @ 3/18/2011 2:38:15 PM
RE: xml and treeview Posted by Yousfi Benameur @ 3/18/2011 6:06:14 PM
RE: xml and treeview Posted by James Frye @ 3/21/2011 2:48:49 PM
RE: xml and treeview Posted by Yousfi Benameur @ 3/21/2011 4:55:56 PM