You are here: Re: [PHP] parse string « PHP « IT news, forums, messages
Re: [PHP] parse string

Posted by "Richard Lynch" on 01/19/06 21:51

On Thu, January 19, 2006 12:08 pm, Ron Eggler (Paykiosks) wrote:
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
> </cardSKU>
> [/xml]
> and I wanna read information out of it by:
> [php]
> $xml = simplexml_load_string($data);
> /* a few other things like parsing xml that works fine */
> foreach ($xml->cardSKU as $cardSKU)
> {
> array_push($category,(string)$cardSKU['category']);
> }
> [/php]
> but it seems not to work, the array $category stays empty, why that?

It's pretty much the same problem you posted yesterday...

category is going to be the $key of the array, not the value.

echo "<pre>xml->cardSKU:<br />\n";
echo "<hr />\n";
foreach($xml->cardSKU as $key => $cardSKU){
echo "key: $key<br />\n"
echo "<hr />\n";

When you don't get the data you expect, use var_dump() on the data
BEFORE that to see where the bits you want exist -- You'll usually
find that they array/key/value/object structure has what you want,
just in different places than you were looking.

Like Music?



[Reply to this 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

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