php, xml, aumenta il trasporto: “Impossibile visualizzare input XML utilizzando XSL ...” Dov'è l'errore?

StackOverflow https://stackoverflow.com/questions/1051492

Domanda

Hey, quindi sto distribuzione di un calcolatore di spedizione utilizzando questa funzione , e sto ottenendo questo errore solo quando uso IE. Firefox fa proprio bene con il calcolatore di trasporto. Sono familiarità con questo errore, e le ricerche di Google mi dicono che si tratta di un problema con il formato XML. Il problema è: la risposta XML dal server di calcolo di trasporto del gruppo di continuità non dovrebbe avere questo contenuto. Quindi, la mia domanda è: dove pensi che il bug è? Apprezzo risposte e suggerimenti su dove per controllare. sto disegnando un vuoto.

errore quando utilizza IE (vrs 8. 7, e 6):

  

La pagina XML non può essere visualizzata   Impossibile visualizzare input XML usando di stile XSL   foglio. Si prega di correggere l'errore e   quindi fare clic sul pulsante Aggiorna, o provare   di nuovo più tardi.

     
     

Sintassi non corretta è stato utilizzato in un   commento. Errore durante l'elaborazione delle risorse   ' http://mgxvideo.com/mgxcopy-alpha-3/shopping/cart_displa ...

<!------------------- main content ------------------------->
     

---------- ^

porzione del codice php che richiede dal server:

$ch = curl_init("https://www.ups.com/ups.app/xml/Rate");
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_TIMEOUT, 90);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        $result=curl_exec ($ch);
    echo '<!-- '. $result. ' -->'; // THIS LINE IS FOR DEBUG PURPOSES ONLY-IT WILL SHOW IN HTML COMMENTS
        $data = strstr($result, '<?');
        $xml_parser = xml_parser_create();
        xml_parse_into_struct($xml_parser, $data, $vals, $index);
        xml_parser_free($xml_parser);
        $params = array();
        $level = array();
        foreach ($vals as $xml_elem) {
         if ($xml_elem['type'] == 'open') {
        if (array_key_exists('attributes',$xml_elem)) {
             list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
        } else {
             $level[$xml_elem['level']] = $xml_elem['tag'];
        }
         }
         if ($xml_elem['type'] == 'complete') {
        $start_level = 1;
        $php_stmt = '$params';
        while($start_level < $xml_elem['level']) {
             $php_stmt .= '[$level['.$start_level.']]';
             $start_level++;
        }
        $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
        eval($php_stmt);
         }
        }
        curl_close($ch);
        #print_r($params);
        #echo "<br/><br/>";
        return $params['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['TOTALCHARGES']['MONETARYVALUE'];

Ed ecco ciò che fa eco Firefox come risultato dalla richiesta xml (nel codice qui sopra, è la riga che dice "questa linea è a scopo di debug SOLO":

<!-- HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Date: Fri, 26 Jun 2009 21:58:04 GMT
Server: Apache
Pragma: no-cache
Content-Length: 1524
Content-Type: application/xml

<?xml version="1.0"?><RatingServiceSelectionResponse><Response><TransactionReference><CustomerContext>Bare Bones Rate Request</CustomerContext><XpciVersion>1.0</XpciVersion></TransactionReference><ResponseStatusCode>1</ResponseStatusCode><ResponseStatusDescription>Success</ResponseStatusDescription></Response><RatedShipment><Service><Code>02</Code></Service><RatedShipmentWarning>Your invoice may vary from the displayed reference rates</RatedShipmentWarning><BillingWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>6.0</Weight></BillingWeight><TransportationCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>14.34</MonetaryValue></TransportationCharges><ServiceOptionsCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>0.00</MonetaryValue></ServiceOptionsCharges><TotalCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>14.34</MonetaryValue></TotalCharges><GuaranteedDaysToDelivery>2</GuaranteedDaysToDelivery><ScheduledDeliveryTime></ScheduledDeliveryTime><RatedPackage><TransportationCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>14.34</MonetaryValue></TransportationCharges><ServiceOptionsCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>0.00</MonetaryValue></ServiceOptionsCharges><TotalCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>14.34</MonetaryValue></TotalCharges><Weight>6.0</Weight><BillingWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>6.0</Weight></BillingWeight></RatedPackage></RatedShipment></RatingServiceSelectionResponse> -->

idee?

È stato utile?

Soluzione

Tecnicamente, non si può avere '-' interno di commenti XML. Così si dovrebbe cambiare:

<!------------------- main content ------------------------->

a

<!--                  main content                     -->

... o qualcosa di simile. Se UPS trasmette il testo. È possibile sostituire prima di trasmetterla al browser.

Modifica

Per quanto riguarda la visualizzazione del marcatore piuttosto che il formato HTML: Se stai vedendo la stessa cosa come in Firefox ( getRate () da API up-php si fa riferimento.

Altri suggerimenti

la questione era di formattazione povera html. Ho eliminato tutti i miei commenti, e per qualche ragione che sta funzionando meglio ora.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top