function updatePublishSet($auth, $cascade, $xmlFilePath, $publishSetID)
{
    // open XML file, read all system-page nodes, store page IDs in array
    $xml = simplexml_load_file($xmlFilePath);
    $xmlResult = $xml->xpath('//system-page');
    $psPagesArray = array();
    while (list(, $node) = each($xmlResult)) {
        $pageID = utf8_encode($node[0]['id']);
        $psPagesArray[] = array('type' => 'page', 'id' => $pageID);
    }
    // get the publish set, replace pages with array from XML file
    $id = array('id' => $publishSetID, 'type' => 'publishset');
    $readParams = array('authentication' => $auth, 'identifier' => $id);
    $publishSetRead = $cascade->read($readParams);
    if ($publishSetRead->readReturn->success == 'true') {
        $asset = $publishSetRead->readReturn->asset->publishSet;
        $asset->pages->publishableAssetIdentifier = $psPagesArray;
        $editParams = array('authentication' => $auth, 'asset' => array('publishSet' => $asset));
        $cascade->edit($editParams);
        $result = $cascade->__getLastResponse();
        getResultAction($result, $asset->name, "updated.");
    } else {
        echo "Couldn't find publish set with ID " . $publishSetID . "\n";
    }
}
function readPage($pageReadID, $auth, $cascade, $pageDateType, $targetDate, $unpublishWorkflowID)
{
    $id = array('id' => $pageReadID, 'type' => 'page');
    $readParams = array('authentication' => $auth, 'identifier' => $id);
    $pageRead = $cascade->read($readParams);
    if ($pageRead->readReturn->success != 'true') {
        echo "looks like it didn't work" . $pageReadID . "\r\n";
    } else {
        $asset = $pageRead->readReturn->asset->page;
        $asset->shouldBePublished = true;
        $fullName = $asset->name;
        if ($pageDateType == 'createdDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->createdDate);
        }
        if ($pageDateType == 'lastModifiedDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->lastModifiedDate);
        }
        if ($pageDateType == 'lastPublishedDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->lastPublishedDate);
        }
        if ($pageDateType == 'reviewDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->metadata->reviewDate);
        }
        if ($pageDateType == 'startDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->metadata->startDate);
        }
        if ($pageDateType == 'endDate') {
            $pageDate = strtotime($pageRead->readReturn->asset->page->metadata->endDate);
        }
        echo $fullName . "\r\n";
        if ($pageDate < $targetDate) {
            $wfParams = array('workflowName' => 'Delete and Unpublish', 'workflowDefinitionId' => $unpublishWorkflowID, 'workflowComments' => 'Deleted via Web Services');
            $editParams = array('authentication' => $auth, 'asset' => array('page' => $asset));
            $editParamWF = array('authentication' => $auth, 'asset' => array('page' => $asset, 'workflowConfiguration' => $wfParams));
            $cascade->edit($editParams);
            $result = $cascade->__getLastResponse();
            getResultAction($result, $fullName, "updated.");
            $cascade->edit($editParamWF);
            $result = $cascade->__getLastResponse();
            getResultAction($result, $fullName, "deleted.");
        }
    }
}