i'm new php. i'm trying to:
- write data xml file variable;
- write data variable file;
the file empty. think has delay during xml file parsing. variable created, empty , that's why file empty. there delay or sort of workaround this?
the code:
$xml = simplexml_load_file("somexmlfilewhichtakestimetoload.xml") or die ("error: cannot create object"); $myfile = fopen("eefuelprice.txt", "w") or die("unable open file!"); print_r($xml); fwrite($myfile, $xml); print_r("successfully wrote file");
thanks in advance!
i'm assuming want work xml xml, rather string ...
note: simplexml_load_file()
blocking function: when returns, file has parsed.
you need error handling: you're printing $xml
assume prints data you're expecting. fwrite()
returns number of bytes written -- return? if it's zero, (which be) issue.
you instead use asxml()
print xml object file. fwrite()
writing bytes (strings) file.
Comments
Post a Comment