Hallo allemaal,

Ben bezig om via TNT Express Connect zelf vrachtbrieven te genereren.
Dit wilt niet helemaal lukken.

Ik krijg namelijk de volgende melding:

Warning: DOMDocument::loadXML(): Empty string supplied as input in /home/roppie2/domains/mijnpompen.nl/public_html/tnt/labelprintone.php on line 27 Fatal error: Class 'XSLTProcessor' not found in /home/roppie2/domains/mijnpompen.nl/public_html/tnt/labelprintone.php on line 30

Mijn script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

function getdata ($xml, $gateway){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$gateway);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml_in='.urlencode($xml));
$response = curl_exec($ch);

if (curl_errno($ch))
print "Error: " . curl_error($ch);

curl_close($ch);
return $response;
}

$url = "http://iConnection.tnt.com:81/shippergate2.asp";
$xml_in = 'GET_LABEL:49514384';

$label = getdata($xml_in, $url);

$xml = new DOMDocument();
$xml->loadXML($label);

$xsl = new DOMDocument();
$xsl->load('http://iConnection.tnt.com:81/Shipper/NewStyleSheets/label.xsl');

$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);

echo $proc->transformToXML($xml);
?>

Heeft iemand enig idee wat ik fout doe?
Moet ik soms de classes nog importeren? Dacht dat die standaard in PHP 5 zaten?
Het lijkt erop dat deze niet meegecompileerd in in PHP?

Wat zegt de configure uit phpinfo()? Ik vermoed dat dit ontbreekt?
--with-xsl=
Dat is werk voor de webhosting.
Feitelijk niets meer dan een regeltje code voor hen, en PHP opnieuw compileren met enkele commando's.
Jeej! hosting heeft het aangezet...


Nu alleen nog steeds de melding:

Warning: DOMDocument::loadXML(): Empty string supplied as input in /home/roppie2/domains/mijnpompen.nl/public_html/tnt/labelprintone.php on line 27
Gokje: $label is leeg / loadXML retourneert niets?
Ja die had ik ook al bedacht Thomas :)

Snap niet waarom hij geen content ophaalt?

[size=xsmall]Toevoeging op 27/10/2015 19:22:08:[/size]

Onderstaande code doet al iets meer.
Maar de errors die hij geeft is omdat de html die terug komt niet geldig is?
Wat als ik die nu toch wil laten zien?

http://www.mijnpompen.nl/tnt/labelprintALL.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

function getdata ($xml, $gateway){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$gateway);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml_in='.urlencode($xml));
$response = curl_exec($ch);

if (curl_errno($ch)) { print "Error: <pre>" . curl_error($ch)."</pre>"; }

curl_close($ch);
return $response;
}

$url = "http://iconnection.tnt.com:81";
$xml_in = 'GET_LABEL:102947784';

$label = getdata($xml_in,$url);

$xml = new DOMDocument;
$xml->loadXML($label);

$xsl = new DOMDocument;
$xsl->load('http://iConnection.tnt.com:81/Shipper/NewStyleSheets/label.xsl');

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);

$html = $proc->transformToXML($xml);

echo $html;
?>

Reageren