當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XML::addXMLasBranch方法代碼示例

本文整理匯總了PHP中XML::addXMLasBranch方法的典型用法代碼示例。如果您正苦於以下問題:PHP XML::addXMLasBranch方法的具體用法?PHP XML::addXMLasBranch怎麽用?PHP XML::addXMLasBranch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XML的用法示例。


在下文中一共展示了XML::addXMLasBranch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: oaidcCollection

function oaidcCollection($result)
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $convertExportDataToUTF8;
    global $citeKeysArray;
    // '$citeKeysArray' is made globally available from
    // within this function
    // Individual records are objects and collections of records are strings
    $oaidcCollectionDoc = new XMLDocument();
    if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") {
        $oaidcCollectionDoc->setEncoding("UTF-8");
    } else {
        $oaidcCollectionDoc->setEncoding($contentTypeCharset);
    }
    $oaidcCollection = new XML("dcCollection");
    $oaidcCollection->setTagAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    $oaidcCollection->setTagAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
    $oaidcCollection->setTagAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    $oaidcCollection->setTagAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
    // ----------------------------------------------------------
    // Add OAI_DC XML entries:
    $exportArray = array();
    // array for individually exported records
    $citeKeysArray = array();
    // array of cite keys (used to ensure uniqueness of cite keys among all exported records)
    // Generate the export for each record and push them onto an array:
    while ($row = @mysql_fetch_array($result)) {
        // Export the current record as OAI_DC XML:
        $record = oaidcRecord($row, "oai_dc");
        if (!empty($record)) {
            // unless the record buffer is empty...
            array_push($exportArray, $record);
        }
        // ...add it to an array of exports
    }
    // for each of the OAI_DC XML entries in the result set...
    foreach ($exportArray as $oaidc) {
        $oaidcCollection->addXMLasBranch($oaidc);
    }
    $oaidcCollectionDoc->setXML($oaidcCollection);
    $oaidcCollectionString = $oaidcCollectionDoc->getXMLString();
    return $oaidcCollectionString;
}
開發者ID:Olari0,項目名稱:Finugriling,代碼行數:44,代碼來源:oaidcxml.inc.php

示例2: modsCollection

function modsCollection($result)
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $convertExportDataToUTF8;
    global $citeKeysArray;
    // '$citeKeysArray' is made globally available from
    // within this function
    // The array '$transtab_refbase_unicode' contains search & replace patterns
    // for conversion from refbase markup to Unicode entities.
    global $transtab_refbase_unicode;
    // defined in 'transtab_refbase_unicode.inc.php'
    global $fieldSpecificSearchReplaceActionsArray;
    // Individual records are objects and collections of records are strings
    $exportArray = array();
    // array for individually exported records
    $citeKeysArray = array();
    // array of cite keys (used to ensure uniqueness of
    // cite keys among all exported records)
    // Defines field-specific search & replace 'actions' that will be applied to all
    // those refbase fields that are listed in the corresponding 'fields' element:
    // (If you don't want to perform any search and replace actions, specify an empty
    //  array, like: '$fieldSpecificSearchReplaceActionsArray = array();'.
    //  Note that the search patterns MUST include the leading & trailing slashes --
    //  which is done to allow for mode modifiers such as 'imsxU'.)
    $fieldSpecificSearchReplaceActionsArray = array();
    if ($convertExportDataToUTF8 == "yes") {
        $fieldSpecificSearchReplaceActionsArray[] = array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_unicode);
    }
    // Generate the export for each record and push them onto an array:
    while ($row = @mysql_fetch_array($result)) {
        // Export the current record as MODS XML
        $record = modsRecord($row);
        if (!empty($record)) {
            // unless the record buffer is empty...
            array_push($exportArray, $record);
        }
        // ...add it to an array of exports
    }
    $modsCollectionDoc = new XMLDocument();
    if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") {
        $modsCollectionDoc->setEncoding("UTF-8");
    } else {
        $modsCollectionDoc->setEncoding($contentTypeCharset);
    }
    $modsCollection = new XML("modsCollection");
    $modsCollection->setTagAttribute("xmlns", "http://www.loc.gov/mods/v3");
    foreach ($exportArray as $mods) {
        $modsCollection->addXMLasBranch($mods);
    }
    $modsCollectionDoc->setXML($modsCollection);
    $modsCollectionString = $modsCollectionDoc->getXMLString();
    return $modsCollectionString;
}
開發者ID:Olari0,項目名稱:Finugriling,代碼行數:54,代碼來源:modsxml.inc.php


注:本文中的XML::addXMLasBranch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。