Hi, all !
I made a request to the site (httpxmlreques). As a result, the ResponseXML property is an XML object. Is it possible to save the object as XML file ?
Creating an XML file
Re: Creating an XML file
nFileHandle := FCreate( "MyDoc.xml", 0 )
// cXml would be your response from the server
FWrite( nFileHandle, cXml )
FClose( nFileHandle )
This should work ....
// cXml would be your response from the server
FWrite( nFileHandle, cXml )
FClose( nFileHandle )
This should work ....
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Re: Creating an XML file
Tim, thank you for your help. But if you save the object in ResponseXML XML file using fwrite, the length of the file equal to 0. Perhaps you first need to convert the ResponseXML object to a string, but I don't know how to do it.
-
- Posts: 16
- Joined: Tue Oct 06, 2015 7:06 am
Re: Creating an XML file
Try ResponseXML:xmlNatter wrote:Hi, all !
I made a request to the site (httpxmlreques). As a result, the ResponseXML property is an XML object. Is it possible to save the object as XML file ?
-
- Posts: 3
- Joined: Thu Sep 01, 2016 1:18 pm
- Location: Rio de Janeiro - Brazil
Re: Creating an XML file
Try this:
MEMOWRIT('c:\response.xml' , cXML , .F.)
MEMOWRIT('c:\response.xml' , cXML , .F.)
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Creating an XML file
If you have an (x)harbour object from class TXml, say oXml, you can make a string by calling:
oXml:ToString( nStyle )
works too, if you don't pass a parameter for style.
The source of the class is in \source\rtl\txml.prg, if you've downloaded (x)harbour source code.
There even is a Method Write, which takes two parameters: fHandle and nStyle
So if you've created a new file and have the handle in fHandle, you could simply call:
oXml:Write( fHandle )
oXml:ToString( nStyle )
works too, if you don't pass a parameter for style.
The source of the class is in \source\rtl\txml.prg, if you've downloaded (x)harbour source code.
There even is a Method Write, which takes two parameters: fHandle and nStyle
So if you've created a new file and have the handle in fHandle, you could simply call:
oXml:Write( fHandle )
Re: Creating an XML file
Thank you all. Understood. Object responceXML empty (the site does not support header to text/xml) so the persistent xml file was also empty.
Re: Creating an XML file
First, I create an xml document: LOCAL oXmlDoc := TXmlDocument():new( )
I also use from windows: iDLL := LoadLibrary( "wininet.dll" )
Then I create the XML I am going to send them. It's a string called cXML ... contains the format they want.
Next, I submit it:
IF .NOT. oHttp:open()
MsgAlert( "Connection error:", oHttp:lastErrorMessage( ) )
RETURN
ENDIF
oHttp:Post( cXml)
cRet := oHttp:readAll( )
oHttp:close()
The value cRet can then be parsed, or written to a file.
At least, it works fine for me this way but may vary depending on how the resource sends you the files.
I also use from windows: iDLL := LoadLibrary( "wininet.dll" )
Then I create the XML I am going to send them. It's a string called cXML ... contains the format they want.
Next, I submit it:
IF .NOT. oHttp:open()
MsgAlert( "Connection error:", oHttp:lastErrorMessage( ) )
RETURN
ENDIF
oHttp:Post( cXml)
cRet := oHttp:readAll( )
oHttp:close()
The value cRet can then be parsed, or written to a file.
At least, it works fine for me this way but may vary depending on how the resource sends you the files.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
Re: Creating an XML file
Tim,
I make XML-files the way you suggested (usingFWRITE, etc;).
It works perfectly.
I make XML-files the way you suggested (usingFWRITE, etc;).
It works perfectly.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Creating an XML file
Michel,
I've been using XML for a couple of years, and now JSON. I usually will be able to deal with most operations in memory by creating an XML formatted output, then parsing the reply. When I need the actual file to be saved, FWRITE has worked fine and the resulting files can be read easily in a browser.
Tim
I've been using XML for a couple of years, and now JSON. I usually will be able to deal with most operations in memory by creating an XML formatted output, then parsing the reply. When I need the actual file to be saved, FWRITE has worked fine and the resulting files can be read easily in a browser.
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019