Reply to SimpleXml Query

Your name:

Reply:


Posted by php_Boi on 02/01/07 01:47

i have a document with this structure. that is loaded from a file with
the name $url.
//valid xml format
<Trip>
<Item>
<Type>Trans</Type>
<Code>KAP</Code>
<Date>20060301</Date>
</Item>
<Item>
<Type>Trans</Type>
<Code>BTL</Code>
<Date>20060301</Date>
</Item>
<Item>
<Type>Sight</Type>
<Code>HTL</Code>
<Date>20060301</Date>
</Item>
</Trip>
Now to get the values of all the items i can do simply enough with

foreach ($url>Trip->Item as $transfer)
{
$vType = $transfer->Type;
$vCode = $transfer->Code;
}

But i need to perform a slightly more complex query.

i need to get the the <Code> and the <Date> only where the <Type> is
"Sight"

tried this but didnt have any luck. (casted as a string so tag wasnt
assumed to be an object)
if ((string) $url->Code == 'Sight') {
print 'Success.';
}
else if((string) $url->Code == 'Trans') {
print 'Success.';
}
else print 'Oh no!';

which will recognize the first node but ignore the ' else if ' (the
node where <Code>Trans</Code> DOES Exist ) and the ' else '???

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация