maddogandnoriko Posted April 8, 2009 Share Posted April 8, 2009 I have an xml page loaded into a simplexml object, and have used xpath as to just work on the episode tags. $episode_data=$this->xml->xpath("/Data/Episode[id=.$tvdbID.]"); When I echo the value of 'SeasonNumber' ($episode->SeasonNumber) I get a number as expected. But if I add $episode->SeasonNumber to an array: $this->seasonList[] = (int)$episode->SeasonNumber[0]; It adds a simplexml object to the array not the number as echoed before, in the end I am trying to end up with a simple array of season #'s. I have tried to include tenough info but not sure. Thank you for any help, maddogandnoriko Link to comment https://forums.phpfreaks.com/topic/153179-add-xml-object-to-array/ Share on other sites More sharing options...
maddogandnoriko Posted April 8, 2009 Author Share Posted April 8, 2009 oops there is also a : $episode_data=$this->xml->xpath("/Data/Episode[id=.$tvdbID.]"); foreach ($episode_data as $episode){ in there. Link to comment https://forums.phpfreaks.com/topic/153179-add-xml-object-to-array/#findComment-804667 Share on other sites More sharing options...
Axeia Posted April 8, 2009 Share Posted April 8, 2009 Not familiar with xpath, so no idea what your code is actually doing, but I do notice a lack of contents access instead of a node. Shouldn't you be access it's contents instead? $this->seasonList[] = $episode->SeasonNumber[0]->textContent; Would be good if you could post your actual code including the foreach, inside [ code] [/ code] tags and surrounded by <?php ?> tags for syntax highlighting. Link to comment https://forums.phpfreaks.com/topic/153179-add-xml-object-to-array/#findComment-804725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.