Probleem met parsen XML via DOMDocument

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Joni Fleischer
Moderator

Joni Fleischer

26/10/2015 22:08:34
Quote Anchor link
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:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?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?
Gewijzigd op 26/10/2015 22:09:25 door Joni Fleischer
 
PHP hulp

PHP hulp

29/03/2024 13:32:57
 
- Ariën  -
Beheerder

- Ariën -

26/10/2015 22:14:10
Quote Anchor link
Het lijkt erop dat deze niet meegecompileerd in in PHP?

Wat zegt de configure uit phpinfo()? Ik vermoed dat dit ontbreekt?
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
--with-xsl=
 
Joni Fleischer
Moderator

Joni Fleischer

26/10/2015 22:33:38
Quote Anchor link
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)???
 
- Ariën  -
Beheerder

- Ariën -

26/10/2015 22:44:36
Quote Anchor link
Dat is werk voor de webhosting.
Feitelijk niets meer dan een regeltje code voor hen, en PHP opnieuw compileren met enkele commando's.
 
Joni Fleischer
Moderator

Joni Fleischer

27/10/2015 18:04:57
Quote Anchor link
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
 
Thomas van den Heuvel

Thomas van den Heuvel

27/10/2015 18:07:14
Quote Anchor link
Gokje: $label is leeg / loadXML retourneert niets?
Gewijzigd op 27/10/2015 18:07:48 door Thomas van den Heuvel
 
Joni Fleischer
Moderator

Joni Fleischer

27/10/2015 18:31:11
Quote Anchor link
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

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?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;
?>
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.