Tuesday, December 6, 2011

Extarct Fedex Shipping Response


 $xmltxt = $client->__getLastResponse(); 
       $xmltxt = preg_replace('#(</?)ns[\d]:#','$1',$xmltxt);     
     //remove all the namespaces that appear in the soap response.
        $xmltxt = preg_replace('#(</?)v[\d]:#','$1',$xmltxt);
         $xmltxt = preg_replace('#(</?)soapenv:#','$1',$xmltxt);
         echo $xmltxt;  
     //debuggig to make sure the SOAP is proper XML and 
         namespaces removed
        $doc = new DOMDocument();  
        $doc->loadXML($xmltxt);        
       $trackingNumber = $doc->getElementsByTagName("TrackingNumber");
        print_r($trackingNumber); //debugging to make sure this exists.
        
        if($trackingNumber = $trackingNumber->item(0)) { 
       //retrieve the first trackingnumber in the elements list.  
                $trackingNumber = $trackingNumber->nodeValue; 
        }  
        
        echo "Tracking Number :::::: ".$trackingNumber;

No comments:

Post a Comment