php, xml, sube el envío: “No se puede ver la entrada XML utilizando XSL ...” ¿Dónde está el error?

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

Pregunta

Hola, así que estoy desplegando una calculadora de envíos utilizando esta función , y yo estoy recibiendo este error sólo cuando utilizo IE. Firefox funciona muy bien con la calculadora de envíos. Estoy familiarizado con este error, y las búsquedas de Google me dicen que es un problema con el formato XML. El problema es: la respuesta XML desde el servidor de cálculo de envío de UPS no debería tener este contenido. Por lo tanto, mi pregunta es: ¿dónde cree que el error es? Aprecio respuestas y sugerencias de lugares para comprobar. Estoy dibujando un espacio en blanco.

error al utilizar IE (VRS 8. 7, y 6):

  

La página XML No se puede mostrar   No se puede ver la entrada XML utilizando XSL   hoja, lámina. Por favor, corrija el error y   a continuación, haga clic en el botón Actualizar o inténtelo   de nuevo más tarde.

     
     

sintaxis incorrecta se utilizó en una   comentario. recurso de procesamiento de error   ' http://mgxvideo.com/mgxcopy-alpha-3/shopping/cart_displa ...

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

---------- ^

parte del código php que solicita desde el servidor:

$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'];

Y esto es lo que se hace eco de Firefox como el resultado de la solicitud XML (en el código anterior, que es la línea que dice "Esta línea es para depuración del código único":

<!-- 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> -->

Las ideas?

¿Fue útil?

Solución

Técnicamente, no se puede tener '-' en el interior de los comentarios XML. Por lo que debe cambiar:

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

a

<!--                  main content                     -->

... o algo similar. Si UPS está enviando. Puede reemplazarlo antes de reenviarlo al navegador.

editar

En cuanto a la muestra marcadores en vez de HTML representado: Si usted está viendo lo mismo que en Firefox ( getRate () de la API de UPS-php que se hace referencia.

Otros consejos

el problema era pobre formato html. He eliminado todos mis comentarios, y por alguna razón que está funcionando mejor ahora.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top