Good afternoon,
I am attempting to loop through approximately 600 XML nodes. Each of those nodes has 2 child nodes (example below). One is an id for an existing page and the other contains values for a page reference field. I have put together a loop (below as well) to attempt to save each page with the label values. This all works....once. After getting the first XML node "label" saved to the correct page, nothing else is saved. I'm sure there is probably something that I have overlooked. But, I am also very new to this CMS. I'm hoping there is a veteran user who may be able to point me in the right direction.
<row>
<id>1041</id>
<labels>lifestyle|savings</labels>
</row>
foreach ($xml->row as $items) {
//get page id to update and set output formatting to false
$blog_page = $pages->get('id='.$items->id);
$blog_page->of(false);
//create array from pipe separated label values
$labelsArray = explode('|', $items->labels);
//loop through array to get page ids by page name
$labelIDS = array();
foreach ($labelsArray as $labelValue) {
$labelPage = $pages->get('name='.$labelValue);
array_push($labelIDS, $labelPage->id);
}
//add labels to label field in post
$blog_page->labels = $labelIDS;
//save page
$blog_page->save();
}