Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: Russell Hill
  Where is Russell Hill?
 Sydney
 Australia
 Russell Hill
 Tags
Subject: RE: Opening an XML file
Thread ID: 228503 Message ID: 228549 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Tuesday, May 19, 2009 9:36:26 PM         
   


> Hi all,
>
> I would like to open an XML file in a VFP form.
>
> I've added an EditBox and used the following in the Click() event:
>
>
This.Value = FILETOSTR(xml_file_name)

> When I do this I get the following result:
>
>
>
> What I'd like to get is what I see when I simply double-click the file through My Computer (as below).
>
>
>
> Can I somehow associate either IE or an XML Editor with the EditBox or do I need a particular control to acheive what I want here?
>
> I tried to find an appropriate OLE control but couldn't do so at a glance.
>
> Thanks,
>
> Russell.

The best solution on a form is without doubt the browser (iexplore).

You can also use these additive solutions:
1-a prg window
MODI comm GETFILE('xml') noedit

this uses a prg window (with coloring,vertical and horizontal scrolls) and one line of code.

2-you can resize your editbox (who dont have Hscroll) width to contain the len of max line.Its usefull for xml file with small widths.This can be done with code.

3-you can use the browse window
ystr=FILETOSTR(GETFILE('xml'))
CREATE CURSOR ycurs (texte M)
INSERT INTO ycurs VALUES (ystr)
BROWSE noedit


4-you can use notepad (or wordpad with fullpath)
afile= GETFILE('xml')
run/n "notepad" &afile


5-You can also use Shellexecute (runs file associated to xml extension).

6-And finally this is the "ice on the cake" with a grid xml viewer
*--Author Yousfi Benameur El Bayadh Algeria
*--Time stamp mardi 19 mai 2009; 20:22:41
*--Subject :View an xml file in a vfp grid

yform=CREATEOBJECT("asup")
yform.show
READ events
RETURN

DEFINE CLASS asup AS form
	Top = 23
	Left = 182
	Height = 365
	Width = 682
	DoCreate = .T.
	showWindow=2
	Caption = "XML Viewer on a grid"
	Name = "form1"

	ADD OBJECT grid1 AS grid WITH ;
		GridLines = 0, ;
		Height = 336, ;
		Left = 0, ;
		Top = 0, ;
		Width = 682, ;
		visible=.f., ;
		Anchor=15,;
		Name = "Grid1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 337, ;
		Left = 288, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "XML...", ;
		Name = "Command1"


	PROCEDURE command1.Click
	LOCAL afile
	    afile=GETFILE('xml')
	    IF EMPTY(afile)
	    RETURN
	    endi
		ystr=FILETOSTR(afile)
		IF EMPTY(ystr)
		RETURN
		endi
		CREATE CURSOR ycurs (myXml c(254))
		FOR i=1 TO MEMLINES(ystr)
		INSERT INTO ycurs VALUES (MLINE(ystr,i))
		ENDFOR
		LOCATE

		WITH thisform.grid1
		.visible=.t.
		.RecordSource=""
		.RecordSource="ycurs"
		.column1.width=1000
		.GridLines=0
		.DeleteMark=.f.
		.RecordMark=.f.
		.ReadOnly=.t.
		.AllowCellSelection=.f.
		.refresh
		.parent.caption="XML Viewer on a grid :"+JUSTFNAME(afile)
		endwith
	ENDPROC
	
	PROCEDURE RESIZE
	this.grid1.width=this.Width-2
	THIS.GRID1.HEIGHT=THIS.Height-THIS.COMMAND1.HEIGHT-2
	this.command1.top=this.Height-this.command1.height-1
	ENDPROC
	
	PROCEDURE DESTROY
	CLEAR EVENTS
	ENDPROC

ENDDEFINE
*!*



Dont rate please.its only for the pleasure to help.Give me only a feed back.
Yousfi Benameur

ENTIRE THREAD

Opening an XML file Posted by Russell Hill @ 5/19/2009 2:18:45 PM
RE: Opening an XML file Posted by Frank Cazabon @ 5/19/2009 2:31:04 PM
RE: Opening an XML file Posted by Russell Hill @ 5/19/2009 2:43:09 PM
RE: Opening an XML file Posted by Frank Cazabon @ 5/20/2009 2:20:10 PM
RE: Opening an XML file Posted by Russell Hill @ 5/21/2009 1:01:07 AM
RE: Opening an XML file Posted by Yuri Rubinov @ 5/19/2009 2:35:42 PM
RE: Opening an XML file Posted by Russell Hill @ 5/19/2009 2:44:07 PM
RE: Opening an XML file Posted by Cetin Basoz @ 5/19/2009 3:01:53 PM
RE: Opening an XML file Posted by Russell Hill @ 5/20/2009 5:29:16 AM
RE: Opening an XML file Posted by Yousfi Benameur @ 5/19/2009 9:36:26 PM
RE: Opening an XML file Posted by Russell Hill @ 5/20/2009 5:31:33 AM
RE: Opening an XML file Posted by Yousfi Benameur @ 5/20/2009 12:15:04 PM
RE: Opening an XML file Posted by Russell Hill @ 5/20/2009 1:40:50 PM