About Store Forum Documentation Contact



Post Reply 
download and use an xml file
Author Message
yvanvds Offline
Member

Post: #1
download and use an xml file
Perhaps I missed something (It wouldn't be the first time), but is there a way to use an xml file on a webserver?

What i try to do is this:
PHP Code:
download.create("http://attr-x.net/updates/version.xml");

.. and 
a bit later ..

if (
download.state() == DWNL_DONE
File f(download.data(), download.size()); 

But what is next? I want to use XmlData on this, but the .load function only accepts a filename. I could save it to disk and load it again:

PHP Code:
if (f.writeTry("version.xml")) myxmlData.load("version.xml"); 

But that seems like an unnecessary step. Also I'd have to wait again, because the writing to disk must be finished before trying to load it, i guess.

So is there a way i can put the downloaded file contents directly into a XmlData structure?

Thanks,

yvan
01-31-2011 02:08 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #2
RE: download and use an xml file
Mmm, how to use that Download structure? I tried to alter the tutorial code a bit to download an xml file instead of an image. But I just end up with an empty file. What's wrong?
PHP Code:
Bool saved;

Bool Init()
{
   
download.create("http://attr-x.net/updates/version.xml");
   
saved false;
   return 
true;
}

/******************************************************************************/
Bool Update()
{
   if(
Kb.bp(KB_ESC))return false;

   if(
download.state()==DWNL_DONE// if all data downloaded successfully
   
{
      if(!
saved// check if we haven't already created it
      
{
         
File f(download.data(),download.size()); // create a file from memory data
         
f.write("version.xml");
         
saved true;
      }
   }
   return 
true;


I also tried other files, like jpg images. All save an empty file on disk after downloading is finished.
01-31-2011 04:01 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: download and use an xml file
I'll add reading xml files from memory! smile

File read(download.data(),download.size()); // create a file from memory data
File write; write.write("version.xml");
read.copy(write);
01-31-2011 04:37 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #4
RE: download and use an xml file
Thanks!
01-31-2011 05:27 PM
Find all posts by this user Quote this message in a reply
Post Reply