Probleem met parsen XML via DOMDocument
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:
Heeft iemand enig idee wat ik fout doe?
Moet ik soms de classes nog importeren? Dacht dat die standaard in PHP 5 zaten?
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:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?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);
?>
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?
Gewijzigd op 26/10/2015 22:09:25 door Joni Fleischer
Het lijkt erop dat deze niet meegecompileerd in in PHP?
Wat zegt de configure uit phpinfo()? Ik vermoed dat dit ontbreekt?
Wat zegt de configure uit phpinfo()? Ik vermoed dat dit ontbreekt?
http://www.mijnpompen.nl/tnt/phpinfo.php
Ff kieken hoor :)
Toevoeging op 26/10/2015 22:35:28:
Geen XSL te vinden :(
En hoe ga ik dat aanzetten (of de host)???
Ff kieken hoor :)
Toevoeging op 26/10/2015 22:35:28:
Geen XSL te vinden :(
En hoe ga ik dat aanzetten (of de host)???
Dat is werk voor de webhosting.
Feitelijk niets meer dan een regeltje code voor hen, en PHP opnieuw compileren met enkele commando's.
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
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?
Gewijzigd op 27/10/2015 18:07:48 door Thomas van den Heuvel
Ja die had ik ook al bedacht Thomas :)
Snap niet waarom hij geen content ophaalt?
Toevoeging op 27/10/2015 19:22:08:
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
Snap niet waarom hij geen content ophaalt?
Toevoeging op 27/10/2015 19:22:08:
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
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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;
?>
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;
?>




