Home  |  Linux  | Mysql  | PHP  | XML
From:TerryA Date:Mon Feb  8 14:36:48 2010
Subject:Re: simplexml - can it do what I need?
Got it! I corrected my syntax and this code now works as far as I can tell:

<?php
$file= 'annnonces.xml';
// load file
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
foreach ($xml->xpath('//lot') as $lot) {
    echo $lot->numero_lot, 'type ', $lot->type, $lot->identification, '<br
/>';
    echo 'Prix maxi: ', $lot->tarif_max, ' Prix mini: ', $lot->tarif_min,
'<br />';
	foreach( $lot->elements->element as $key => $data ){
			$result=((string) $data->attributes());
			if ($result == "1") {
          		echo "Nombre pièces: ", $data, '<br />';
			}
			if ($result == "3") {
          		echo "Surface: ", $data, "m2", '<br />';
			}
			if ($result == "7") {
          		echo "Nombre étoiles: ", $data, '<br />';
				break;
			}
	}
}
?>

Output is:
201type APPARTEMENT STUDIOTEE2 106
Prix maxi: 475 Prix mini: 475
Nombre pièces: 1
Surface: 27m2
Nombre étoiles: 3

Hooray and thanks to all of you guys.

Terry
-- 
View this message in context: http://old.nabble.com/simplexml---can-it-do-what-I-need--tp27481222p27500759.html
Sent from the PHP - General mailing list archive at Nabble.com.

Navigate in group php.general at sever news.php.net
Previous Next


Your recent visits
Re: script working from shell, but not from browser.
Re: [PHP] php selecting multiple stylesheets
cvs: pecl /phar phar.c tar.c
PHP 5.3.1 php-cgi missing from installation
RE: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?


  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants