| 12
 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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 
 | <?php
 
 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	if (!empty($_POST['in'])) {
		$url = 'http://129.194.19.89/Parser';
		$contexte = stream_context_create(
		array(
                'http' => array(
                    'method' => 'post',
					//'header' => "Content-type: text/xml",
                    'header' => "User-Agent: PHP5 & DOM/SimpleXML\r\nContent-type: application/x-www-form-urlencoded ",
                    'content' => http_build_query($_POST),
                    'max_redirects' => 2,
                    'timeout' => 5,
		)
		)
		);
		libxml_set_streams_context($contexte);
		echo "1";
 
		$sxml = simplexml_load_file($url); // Il faudrait tester que $sxml ne vaut pas FALSE ici s'il y a erreur
 
 
		//print_r ($sxml);
 
 
		//transformation du xml avec la xsl correspondante
		$xslDoc = new DOMDocument();
		$xslDoc->load("xslt/transformHTML.xsl");
 
		$xmlDoc = new DOMDocument();
		$xmlDoc->load($url);
 
		//afficher fichier xml
		//echo $xmlDoc->saveXML();
 
		// Sauver le document XML sous le nom simple.xml
 		//$xmlDoc->save('simple.xml');
 
		$proc = new XSLTProcessor();
		$proc->importStylesheet($xslDoc);
 
		echo $proc->transformToXML($xmlDoc);
 
 
	} else {
		echo "0";
		echo "PROBLEME AVEC LE XML!!";
		// ...
	}
}
?> | 
Partager