here is come code (not exactly what you need) that sends an XML
file(variable) to an XML server, and then gets the XML response from
the server and writes it out to a file, returning the filename as the
function return for the php file to resume its processing of the file
in the XML parser (yet another function)

Tried to cut out totally irrelavent or site specific stuff, and added
a few quick comments.  Hopefuly you can follow the logic.

Dave

#### in main PHP file ####
<?
        include("./Shipping/shipping.php");
        include("./Shipping/shipping2.php");
        # process variables and submit = outputs to file, get file name
        $xmlFile = ShippingQuote($variables,$to,$pass,$to,$function);
        # process file
        $xmlOutput = ShippingParse($xmlFile);
?>


#### in ./shipping/shipping.php ####
<?
function ShippingQuote($variables,$to,$pass,$to,$function) {
        #use database and variables to format and send XML document
        $sockPointer = fsockopen("123.456.789.0",50000, &$errNo, &$errStr,
30);
        if (!$sockPointer) {
                echo "$errStr ($errNo)<br>\n";
        } else {
                $xmlTransmit="<?xml version=\"1.0\" ?>\n
                        # assembing and formatting the XML document for transmission
                        \n";
                fputs ($sockPointer, $xmlTransmit);
#
# get the response from the server
#
                while (!feof($sockPointer)) {
                        $socketResponse=fgets($sockPointer,4096);
                        $xmlResponse="$xmlResponse".$socketResponse;
                }
        fclose($sockPointer);
        }
#
# here is the stuff you were really interested in
#
# get a timestamp to save the temp file as
        $xmlFile=time();
# create the temp file
        $xmlFile="./shipping/".$xmlFile.".xml";
        $xfp=fopen($xmlFile,"w");
# write the temp file from the response variable
        fwrite($xfp,$xmlResponse);
        fclose($xfp);
# return the temp filename for the parser to process
        return $xmlFile;
}



#### in ./shipping/shipping2.php ####
<?
function ShippingParse($xmlFile) {
        # Do your parsing
        # clean up the temp file
        system("rm $xmlFile");
        # dump reformatted XML > HTML file out of the function
        return $returnShipTable;
}
?>
-----Original Message-----
From: Steve Haemelinck [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 11, 2001 9:12 AM
To: 'Dave'
Cc: PHP Mailing Listl (E-mail)
Subject: RE: [PHP] XML Parsing The Sequel II


But how can I automate the saving locally of the file !!!

 -----Original Message-----
From:   Dave [mailto:[EMAIL PROTECTED]]
Sent:   zondag 11 februari 2001 14:44
To:     PHP Mailing Listl (E-mail)
Subject:        RE: [PHP] XML Parsing The Sequel II

here is some logic, I'm sure you can flesh out the code.

fopen -r the URL
read the results into a variable, fopen -w to write a local temp file
(if the parser you build actially requires a "file")
save it locally and pass the filename variable to your XML parser
function

if your parser can work from a variable, then just pass the read
variable to your parser.

Dave
<clipped>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to