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


PHP XMLReader::close方法代码示例

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


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

示例1: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     if (!is_file($filename)) {
         v("Can't find Version information file (%s), skipping!", $filename, E_USER_WARNING);
         return array();
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         v("Can't open the version info file (%s)", $filename, E_USER_ERROR);
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("-", "-", "-", "-", ""), $r->value)) && $r->moveToAttribute("from") && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:robertop,项目名称:phd,代码行数:25,代码来源:XHTML.php

示例2: scan

 /**
  * @throws RuntimeException
  * @return array of arrays.
  *         array( 'dumpKey' => array( 'match1', 'match2' ) )
  */
 public function scan()
 {
     $openSuccess = $this->reader->open($this->dumpLocation);
     if (!$openSuccess) {
         throw new RuntimeException('Failed to open XML: ' . $this->dumpLocation);
     }
     $result = array();
     foreach ($this->query as $queryKey => $query) {
         $result[$queryKey] = array();
         // Make sure keys are returned even if empty
     }
     while ($this->reader->read() && $this->reader->name !== 'page') {
     }
     while ($this->reader->name === 'page') {
         $element = new SimpleXMLElement($this->reader->readOuterXML());
         $page = $this->getPageFromElement($element);
         foreach ($this->query as $queryKey => $query) {
             $match = $this->matchPage($page, $query);
             if ($match) {
                 //TODO allow the user to choose what to return
                 $result[$queryKey][] = $page->getTitle()->getTitle();
             }
         }
         $this->reader->next('page');
     }
     $this->reader->close();
     return $result;
 }
开发者ID:addwiki,项目名称:mediawiki-dump,代码行数:33,代码来源:DumpScanner.php

示例3: getClioNum

function getClioNum($appurl, $link)
{
    $clio = $current = $currentA = "";
    $reader = new XMLReader();
    $clioQ = $appurl . '/getSingleStuff.xq?doc=' . $link . '_ead.xml&section=summary';
    $reader->open($clioQ);
    while ($reader->read()) {
        if ($reader->name == "unitid" && $reader->getAttribute("type") == "clio") {
            if ($reader->nodeType == XMLReader::ELEMENT) {
                $currentA = "clio";
            } else {
                if ($reader->nodeType == XMLReader::END_ELEMENT) {
                    $currentA = "";
                }
            }
        }
        //echo "{$reader->name} and $currentA<br />";
        if ($reader->name == "#text" && $currentA == "clio") {
            $clio = $reader->value;
            // there can be only one
        }
    }
    // end WHILE
    $reader->close();
    return $clio;
}
开发者ID:cul,项目名称:findingaids,代码行数:26,代码来源:clio.php

示例4: parseSparqlResults

 /**
  * Parse the passed in Sparql XML string into a more easily usable format.
  *
  * @param string $sparql
  *   A string containing Sparql result XML.
  *
  * @return array
  *   Indexed (numerical) array, containing a number of associative arrays,
  *   with keys being the same as the variable names in the query.
  *   URIs beginning with 'info:fedora/' will have this beginning stripped
  *   off, to facilitate their use as PIDs.
  */
 public static function parseSparqlResults($sparql)
 {
     // Load the results into a XMLReader Object.
     $xmlReader = new XMLReader();
     $xmlReader->xml($sparql);
     // Storage.
     $results = array();
     // Build the results.
     while ($xmlReader->read()) {
         if ($xmlReader->localName === 'result') {
             if ($xmlReader->nodeType == XMLReader::ELEMENT) {
                 // Initialize a single result.
                 $r = array();
             } elseif ($xmlReader->nodeType == XMLReader::END_ELEMENT) {
                 // Add result to results
                 $results[] = $r;
             }
         } elseif ($xmlReader->nodeType == XMLReader::ELEMENT && $xmlReader->depth == 3) {
             $val = array();
             $uri = $xmlReader->getAttribute('uri');
             if ($uri !== NULL) {
                 $val['value'] = self::pidUriToBarePid($uri);
                 $val['uri'] = (string) $uri;
                 $val['type'] = 'pid';
             } else {
                 //deal with any other types
                 $val['type'] = 'literal';
                 $val['value'] = (string) $xmlReader->readInnerXML();
             }
             $r[$xmlReader->localName] = $val;
         }
     }
     $xmlReader->close();
     return $results;
 }
开发者ID:MarmotLibraryNetwork,项目名称:islandora_import,代码行数:47,代码来源:RepositoryQuery.php

示例5: parseFile

 /**
  * @param \Closure $callback
  */
 protected function parseFile(\Closure $callback)
 {
     while ($this->xmlr->localName == $this->node) {
         try {
             $sxe = new \SimpleXMLElement($this->xmlr->readOuterXml());
             if (!$sxe instanceof \SimpleXMLElement) {
                 throw new \Exception("node is note SimpleXMLElement");
             }
             $callback($sxe);
         } catch (\RuntimeException $e) {
             throw new \RuntimeException($e->getMessage());
         } catch (\Exception $e) {
             if ($this->trace) {
                 echo sprintf("%s - %s - %s -%s\n", $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
             }
             if ($this->strict) {
                 throw new \RuntimeException($e->getMessage());
             }
         }
         if ($this->debug) {
             break;
         }
         $this->xmlr->next($this->node);
     }
     $this->xmlr->close();
 }
开发者ID:tvart,项目名称:libs,代码行数:29,代码来源:XmlParser.php

示例6: doRewind

 /**
  * @inheritdoc
  */
 protected function doRewind()
 {
     $this->reader->close();
     $this->open($this->resource->getFile()->getPathname());
     $this->key = -1;
     $this->next();
 }
开发者ID:treehouselabs,项目名称:feeder,代码行数:10,代码来源:XmlReader.php

示例7: initialize

 /**
  * Reads the configuration file and creates the class attributes
  *
  */
 protected function initialize()
 {
     $reader = new XMLReader();
     $reader->open(parent::getConfigFilePath());
     $reader->setRelaxNGSchemaSource(self::WURFL_CONF_SCHEMA);
     libxml_use_internal_errors(TRUE);
     while ($reader->read()) {
         if (!$reader->isValid()) {
             throw new Exception(libxml_get_last_error()->message);
         }
         $name = $reader->name;
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 $this->_handleStartElement($name);
                 break;
             case XMLReader::TEXT:
                 $this->_handleTextElement($reader->value);
                 break;
             case XMLReader::END_ELEMENT:
                 $this->_handleEndElement($name);
                 break;
         }
     }
     $reader->close();
     if (isset($this->cache["dir"])) {
         $this->logDir = $this->cache["dir"];
     }
 }
开发者ID:eusholli,项目名称:drupal,代码行数:32,代码来源:XmlConfig.php

示例8: close

 /**
  * @inheritdoc
  */
 public function close()
 {
     if (!isset($this->xmlReader)) {
         throw new \RuntimeException('The resource needs to be open.');
     }
     $this->xmlReader->close();
     unset($this->xmlReader);
 }
开发者ID:yosmanyga,项目名称:resource,代码行数:11,代码来源:XmlFileReader.php

示例9: parse

 public function parse($file)
 {
     $this->currentFile = new \SplFileObject($file);
     $this->path = [];
     $this->xmlReader->open($file);
     $this->read();
     $this->xmlReader->close();
 }
开发者ID:gillbeits,项目名称:commerceml,代码行数:8,代码来源:Parser.php

示例10: parse

 /**
  * Parse a beer XML, returning an array of the record objects found
  *
  * @param string $xml
  * @return IRecipe[]|IEquipment[]|IFermentable[]|IHop[]|IMashProfile[]|IMisc[]|IStyle[]|IWater[]|IYeast[]
  */
 public function parse($xml)
 {
     $this->xmlReader->XML($xml);
     $records = array();
     while ($this->xmlReader->read()) {
         // Find records
         if ($this->xmlReader->nodeType == \XMLReader::ELEMENT && isset($this->tagParsers[$this->xmlReader->name])) {
             $recordParser = new $this->tagParsers[$this->xmlReader->name]();
             /** @var $recordParser Record */
             $recordParser->setXmlReader($this->xmlReader);
             $recordParser->setRecordFactory($this->recordFactory);
             $records[] = $recordParser->parse();
         }
     }
     $this->xmlReader->close();
     return $records;
 }
开发者ID:georgeh,项目名称:php-beerxml,代码行数:23,代码来源:Parser.php

示例11: assertDumpEnd

 /**
  * Asserts that the xml reader is at the final closing tag of an xml file and
  * closes the reader.
  *
  * @param $tag string: (optional) the name of the final tag
  *           (e.g.: "mediawiki" for </mediawiki>)
  */
 protected function assertDumpEnd($name = "mediawiki")
 {
     $this->assertNodeEnd($name, false);
     if ($this->xml->read()) {
         $this->skipWhitespace();
     }
     $this->assertEquals($this->xml->nodeType, XMLReader::NONE, "No proper entity left to parse");
     $this->xml->close();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:16,代码来源:DumpTestCase.php

示例12: rewind

 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     if ($this->xml) {
         $this->xml->close();
     }
     $this->xml = new \XMLReader();
     $this->xml->open($this->path);
     $this->next();
 }
开发者ID:jackbzne,项目名称:spreadsheet-parser,代码行数:12,代码来源:RowIterator.php

示例13: importXML

 function importXML($file)
 {
     global $opt;
     $xr = new XMLReader();
     if (!$xr->open($file)) {
         $xr->close();
         return;
     }
     $xr->read();
     if ($xr->nodeType != XMLReader::ELEMENT) {
         echo 'error: First element expected, aborted' . "\n";
         return;
     }
     if ($xr->name != 'gkxml') {
         echo 'error: First element not valid, aborted' . "\n";
         return;
     }
     $startupdate = $xr->getAttribute('date');
     if ($startupdate == '') {
         echo 'error: Date attribute not valid, aborted' . "\n";
         return;
     }
     while ($xr->read() && !($xr->name == 'geokret' || $xr->name == 'moves')) {
     }
     $nRecordsCount = 0;
     do {
         if ($xr->nodeType == XMLReader::ELEMENT) {
             $element = $xr->expand();
             switch ($xr->name) {
                 case 'geokret':
                     $this->importGeoKret($element);
                     break;
                 case 'moves':
                     $this->importMove($element);
                     break;
             }
             $nRecordsCount++;
         }
     } while ($xr->next());
     $xr->close();
     setSysConfig('geokrety_lastupdate', date($opt['db']['dateformat'], strtotime($startupdate)));
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:42,代码来源:geokrety.class.php

示例14: parse

 /**
  * Creates a Map of devices from the xml file
  *
  * @param string $fileName path to the xml file to parse
  * @return Map of <deviceId ModelDevice>
  */
 public static function parse($fileName, $validationSchema)
 {
     $devicesMap = array();
     $deviceID = null;
     $groupID = null;
     $reader = new XMLReader();
     $reader->open($fileName);
     $fullFileName = dirname(__FILE__) . DIRECTORY_SEPARATOR . $validationSchema;
     $reader->setRelaxNGSchema($fullFileName);
     libxml_use_internal_errors(TRUE);
     while ($reader->read()) {
         if (!$reader->isValid()) {
             throw new Exception(libxml_get_last_error()->message);
         }
         $nodeName = $reader->name;
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 switch ($nodeName) {
                     case WURFL_Xml_Interface::DEVICE:
                         $groupIDCapabilitiesMap = array();
                         $deviceID = $reader->getAttribute(WURFL_Xml_Interface::ID);
                         $userAgent = $reader->getAttribute(WURFL_Xml_Interface::USER_AGENT);
                         $fallBack = $reader->getAttribute(WURFL_Xml_Interface::FALL_BACK);
                         $actualDeviceRoot = $reader->getAttribute(WURFL_Xml_Interface::ACTUAL_DEVICE_ROOT);
                         $currentCapabilityNameValue = array();
                         if ($reader->isEmptyElement) {
                             $device = new WURFL_Xml_ModelDevice($deviceID, $userAgent, $fallBack, $actualDeviceRoot);
                             $devicesMap[$deviceID] = $device;
                         }
                         break;
                     case WURFL_Xml_Interface::GROUP:
                         $groupID = $reader->getAttribute(WURFL_Xml_Interface::GROUP_ID);
                         $groupIDCapabilitiesMap[$groupID] = array();
                         break;
                     case WURFL_Xml_Interface::CAPABILITY:
                         $capabilityName = $reader->getAttribute(WURFL_Xml_Interface::CAPABILITY_NAME);
                         $capabilityValue = $reader->getAttribute(WURFL_Xml_Interface::CAPABILITY_VALUE);
                         $currentCapabilityNameValue[$capabilityName] = $capabilityValue;
                         $groupIDCapabilitiesMap[$groupID][$capabilityName] = $capabilityValue;
                         break;
                 }
                 break;
             case XMLReader::END_ELEMENT:
                 if ($nodeName == WURFL_Xml_Interface::DEVICE) {
                     $device = new WURFL_Xml_ModelDevice($deviceID, $userAgent, $fallBack, $actualDeviceRoot, $groupIDCapabilitiesMap);
                     $devicesMap[$device->id] = $device;
                 }
                 break;
         }
     }
     // end of while
     $reader->close();
     return $devicesMap;
 }
开发者ID:eusholli,项目名称:drupal,代码行数:60,代码来源:ParserUtil.php

示例15: Decode

 public static function Decode($XMLResponse, &$isFault)
 {
     $responseXML = null;
     try {
         if (empty($XMLResponse)) {
             throw new Exception("Given Response is not a valid SOAP response.");
         }
         $xmlDoc = new XMLReader();
         $res = $xmlDoc->XML($XMLResponse);
         if ($res) {
             $xmlDoc->read();
             $responseXML = $xmlDoc->readOuterXml();
             $xmlDOM = new DOMDocument();
             $xmlDOM->loadXML($responseXML);
             $isFault = trim(strtoupper($xmlDoc->localName)) == self::$FaultMessage;
             if ($isFault) {
                 $xmlDOM->loadXML($xmlDoc->readOuterXml());
             }
             switch ($xmlDoc->nodeType) {
                 case XMLReader::ELEMENT:
                     $nodeName = $xmlDoc->localName;
                     $prefix = $xmlDoc->prefix;
                     if (class_exists($nodeName)) {
                         $xmlNodes = $xmlDOM->getElementsByTagName($nodeName);
                         foreach ($xmlNodes as $xmlNode) {
                             //$xmlNode->prefix = "";
                             $xmlNode->setAttribute("_class", $nodeName);
                             $xmlNode->setAttribute("_type", "object");
                         }
                     }
                     break;
             }
             $responseXML = $xmlDOM->saveXML();
             $unserializer = new XML_Unserializer();
             $unserializer->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
             $res = $unserializer->unserialize($responseXML, false);
             if ($res) {
                 $responseXML = $unserializer->getUnserializedData();
             }
             $xmlDoc->close();
         } else {
             throw new Exception("Given Response is not a valid XML response.");
         }
     } catch (Exception $ex) {
         throw new Exception("Error occurred while XML decoding");
     }
     return $responseXML;
 }
开发者ID:christopherreay,项目名称:freeFreeCrowdfunding_ignitiondeck_crowdfunding,代码行数:48,代码来源:XMLEncoder.php


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