當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。