Then var_dump($xml) and see what's in there. The data you want is in there somewhere -- you just need to figure out where it is. On Thu, January 19, 2006 3:10 pm, Ron Eggler (Paykiosks) wrote: > Am Donnerstag, den 19.01.2006, 13:51 -0600 schrieb Richard Lynch: >> 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"; >> var_dump($xml->cardSKU); >> echo "<hr />\n"; >> foreach($xml->cardSKU as $key => $cardSKU){ >> echo "key: $key<br />\n" >> var_dump($cardSKU); >> 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. >> > Sorry, I can' really get it :( > I inserted your code and got this: > [html] > <pre>xml->cardSKU:<br /> > object(SimpleXMLElement)#3 (0) { > } > <hr /> > [/html] > shouldn't there be listed all elements of 'category'? > Thanks again and sorry if I'm driving you crazy by that but it's the > really first time I'm doing something like that... > > __________________________________________ > > Ron Eggler > Intern > 866-999-4179 > www.paykiosks.net > > > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php