当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLParser::parseText方法代码示例

本文整理汇总了PHP中XMLParser::parseText方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::parseText方法的具体用法?PHP XMLParser::parseText怎么用?PHP XMLParser::parseText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::parseText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XMLParser

 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     $returner =& $this->handleRootNode($result);
     $result->destroy();
     $xmlParser->destroy();
     return $returner;
 }
开发者ID:Rygbee,项目名称:harvester,代码行数:15,代码来源:ModsPlugin.inc.php

示例2: XMLParser

 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     $modsNode =& $result->getChildByName(array('oai_mods:mods', 'mods:mods', 'mods'));
     if (!isset($modsNode)) {
         $returner = null;
         return $returner;
     }
     $returner =& $this->handleRootNode($modsNode);
     $result->destroy();
     $xmlParser->destroy();
     return $returner;
 }
开发者ID:jalperin,项目名称:harvester,代码行数:20,代码来源:ModsPlugin.inc.php

示例3: foreach

 /**
  * SUSHI report
  * @param $useLegacyStats boolean
  */
 function _sushiXML($useLegacyStats)
 {
     $templateManager =& TemplateManager::getManager();
     $SOAPRequest = file_get_contents('php://input');
     // crude handling of namespaces in the input
     // FIXME: only the last prefix in the input will be used for each namespace
     $soapEnvPrefix = '';
     $sushiPrefix = '';
     $counterPrefix = '';
     $re = '/xmlns:([^=]+)="([^"]+)"/';
     preg_match_all($re, $SOAPRequest, $mat, PREG_SET_ORDER);
     foreach ($mat as $xmlns) {
         $modURI = $xmlns[2];
         if (strrpos($modURI, '/') + 1 == strlen($modURI)) {
             $modURI = substr($modURI, 0, -1);
         }
         switch ($modURI) {
             case 'http://schemas.xmlsoap.org/soap/envelope':
                 $soapEnvPrefix = $xmlns[1];
                 break;
             case 'http://www.niso.org/schemas/sushi':
                 $sushiPrefix = $xmlns[1];
                 break;
             case 'http://www.niso.org/schemas/sushi/counter':
                 $counterPrefix = $xmlns[1];
                 break;
         }
     }
     if (strlen($soapEnvPrefix) > 0) {
         $soapEnvPrefix .= ':';
     }
     if (strlen($sushiPrefix) > 0) {
         $sushiPrefix .= ':';
     }
     if (strlen($counterPrefix) > 0) {
         $counterPrefix .= ':';
     }
     $parser = new XMLParser();
     $tree = $parser->parseText($SOAPRequest);
     $parser->destroy();
     // is this necessary?
     if (!$tree) {
         $templateManager->assign('Faultcode', 'Client');
         $templateManager->assign('Faultstring', 'The parser was unable to parse the input.');
         header("HTTP/1.0 500 Internal Server Error");
         $templateManager->display($this->getTemplatePath() . 'soaperror.tpl', 'text/xml');
     } else {
         $reportRequestNode = $tree->getChildByName($soapEnvPrefix . 'Body')->getChildByName($counterPrefix . 'ReportRequest');
         $requestorID = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'ID')->getValue();
         $requestorName = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'Name')->getValue();
         $requestorEmail = $reportRequestNode->getChildByName($sushiPrefix . 'Requestor')->getChildByName($sushiPrefix . 'Email')->getValue();
         $customerReferenceID = $reportRequestNode->getChildByName($sushiPrefix . 'CustomerReference')->getChildByName($sushiPrefix . 'ID')->getValue();
         $reportName = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getAttribute('Name');
         $reportRelease = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getAttribute('Release');
         $usageDateRange = $reportRequestNode->getChildByName($sushiPrefix . 'ReportDefinition')->getChildByName($sushiPrefix . 'Filters')->getChildByName($sushiPrefix . 'UsageDateRange');
         $usageDateBegin = $usageDateRange->getChildByName($sushiPrefix . 'Begin')->getValue();
         $usageDateEnd = $usageDateRange->getChildByName($sushiPrefix . 'End')->getValue();
         $this->_assignTemplateCounterXML($templateManager, $usageDateBegin, $usageDateEnd, $useLegacyStats);
         $templateManager->assign('requestorID', $requestorID);
         $templateManager->assign('requestorName', $requestorName);
         $templateManager->assign('requestorEmail', $requestorEmail);
         $templateManager->assign('customerReferenceID', $customerReferenceID);
         $templateManager->assign('reportName', $reportName);
         $templateManager->assign('reportRelease', $reportRelease);
         $templateManager->assign('usageDateBegin', $usageDateBegin);
         $templateManager->assign('usageDateEnd', $usageDateEnd);
         $templateManager->assign('templatePath', $this->getTemplatePath());
         $templateManager->display($this->getTemplatePath() . 'sushixml.tpl', 'text/xml');
     }
 }
开发者ID:jasonzou,项目名称:OJS-2.4.6,代码行数:74,代码来源:CounterReportPlugin.inc.php

示例4: XMLParser

 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     foreach ($result->getChildren() as $child) {
         $name = $child->getName();
         $value = $child->getValue();
         if (String::substr($name, 0, 6) == 'etdms:') {
             $name = String::substr($name, 3);
         }
         $returner[$name][] = $value;
     }
     $result->destroy();
     $xmlParser->destroy();
     unset($result, $xmlParser);
     return $returner;
 }
开发者ID:ramonsodoma,项目名称:harvester,代码行数:23,代码来源:EtdmsPlugin.inc.php

示例5: XMLParser

 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     foreach ($result->getChildren() as $child) {
         $name = $child->getName();
         switch ($child->getName()) {
             case 'varfield':
                 $id = $child->getAttribute('id');
                 $i1 = $child->getAttribute('i1');
                 $i2 = $child->getAttribute('i2');
                 foreach ($child->getChildren() as $subfield) {
                     if ($subfield->getName() != 'subfield') {
                         continue;
                     }
                     $value = $subfield->getValue();
                     if (empty($value)) {
                         continue;
                     }
                     $label = $subfield->getAttribute('label');
                     $returner[$id][$i1][$i2][$label][] = $value;
                 }
                 break;
             case 'datafield':
                 $id = $child->getAttribute('tag');
                 $i1 = $child->getAttribute('ind1');
                 $i2 = $child->getAttribute('ind2');
                 foreach ($child->getChildren() as $subfield) {
                     if ($subfield->getName() != 'subfield') {
                         continue;
                     }
                     $value = $subfield->getValue();
                     if (empty($value)) {
                         continue;
                     }
                     $label = $subfield->getAttribute('code');
                     $returner[$id][$i1][$i2][$label][] = $value;
                 }
                 break;
             case 'controlfield':
                 break;
         }
     }
     $result->destroy();
     $xmlParser->destroy();
     unset($result, $xmlParser);
     return $returner;
 }
开发者ID:Rygbee,项目名称:harvester,代码行数:54,代码来源:MarcPlugin.inc.php


注:本文中的XMLParser::parseText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。