Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Save XML file using Explorer
Message
From
09/11/2021 07:18:56
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Save XML file using Explorer
Miscellaneous
Thread ID:
01682662
Message ID:
01682662
Views:
37
Hello comunity,

I build a program to create an XML file, but i have a problem because when i use PUTFILE() i cannot create my XML file on the location.
Here is my code:
tmpXML = ""
CabXML = ""
EndXML = ""

Select BO
TEXT to CabXML textmerge noshow
				<Documento>
				<Documentonumber><<bo.obrano>></Documentonumber>
				<DocumentoData><<bo.Dataobra>></DocumentoData>
				</Documento>
ENDTEXT
Select bi
Scan
	If(!Empty(Alltrim(bi.ref)))

		*!*		> &gt;
		*!*		< &lt;
		*!*		& &amp;
		*!*		' &apos;
		*!*		" &quot;
		*!*<Designacao><<alltrim(CHRTRANC(bi.Design, '&',' &amp; '))>></Designacao>
		*!*<Designacao><<ALLTRIM(CAST(ICASE(like('*&*',bi.design), CHRTRANC(bi.Design, '&',' &amp; '),bi.design) as C(60)))>></Designacao>

		m.valor = Alltrim(bi.Design)
		TEXT to lineXML textmerge noshow
 				<Linhas>
					<Referencia><<alltrim(bi.ref)>></Referencia>
					<Designacao><<ALLTRIM(escapar(transform(m.valor)))>></Designacao>
					<Quantidade><<bi.qtt>></Quantidade>
					<PVP><<bi.edebito>></PVP>
					<Fornecedor><<bi.edebito>></Fornecedor>
					<Uneco><<bi.edebito>></Uneco>
					<PVP><<bi.edebito>></PVP>
	 			</Linhas>
		ENDTEXT

		tmpXML = tmpXML + lineXML + Chr(13)
	Endif
Endscan

EndXML = CabXML + tmpXML

TEXT to finalXML textmerge noshow
<?xml version="1.0" encoding="Windows-1252" standalone="yes"?>
<VFPDataSet>
<<EndXML>>
</VFPDataSet>
ENDTEXT



** export click
gcDelimFile = Putfile([guardar como] , 'finalXML' , 'Xml')

m.xml_file_name = StrToFile(finalXML,"finalXML.XML") 

If !Empty(m.gcDelimFile)

	Copy To (gcDelimFile) &&Type XML

	MSG("Exportação realizada com sucesso..!!")
Else
	Messagebox("Exportação cancelada pelo Utilizador!",0+64,"Oppppssss!!!!")
Endif

*msg(finalXML)

*-------------------------------
Function escapar(valor)
	*-------------------------------
	If Len(Chrtran(m.valor,["'<>&],'')) # Len(m.valor)
		valor = Strtran(m.valor,[&],[&amp;])
		valor = Strtran(m.valor,['],[&apos;])
		valor = Strtran(m.valor,[<],[&lt;])
		valor = Strtran(m.valor,[>],[&gt;])
		valor = Strtran(m.valor,["],[&quot;])
	Endif

	Return m.valor
Please someone could help me.

Many thanks,
Best regards,
Luis
Next
Reply
Map
View

Click here to load this message in the networking platform