Home  |  Linux  | Mysql  | PHP  | XML
From:TerryA Date:Mon Feb  8 09:04:05 2010
Subject:Re: simplexml - can it do what I need?

Hi Guys

Thanks for all your input. This forum is great! I can get the attributes OK
but I can't code the checking routing correctly. This is what I have:

Many thanks again for your input. I tried this but it only gives me the data
for each element. I need to be able to access the attributes of the data in
order to select only those elements that I need. This is the code that I
have at present:

<?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='17') {
echo $data;
}
}
}
?>

But this just gives the data for every element. Any ideas on how to get just
the data for the element when the attribute is 17?

Terry
--
View this message in context: http://old.nabble.com/simplexml---can-it-do-what-I-need--tp27481222p27496987.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: [PHP] php selecting multiple stylesheets
cvs: pecl /llvm phpllvm.cpp phpllvm_compile.cpp phpllvm_execute.cpp phpllvm_execute.h
Re: [PHP] php selecting multiple stylesheets
Re: [PHP] php selecting multiple stylesheets
Re: [PHP] removing an array from a compound array



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants