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


PHP XMLReader::readString方法代码示例

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


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

示例1: parse

 /**
  * @throws BadData
  * @return mixed
  */
 public function parse()
 {
     $record = $this->createRecord();
     // While this recipe is still open
     while ($this->tagName != $this->xmlReader->name || \XMLReader::END_ELEMENT != $this->xmlReader->nodeType) {
         if (!@$this->xmlReader->read()) {
             throw new BadData('Surprise end of file! Missing close tag <' . $this->tagName . '>');
         }
         if ($this->xmlReader->isEmptyElement) {
             continue;
         }
         if (\XMLReader::ELEMENT == $this->xmlReader->nodeType) {
             if (isset($this->simpleProperties[$this->xmlReader->name])) {
                 $method = $this->simpleProperties[$this->xmlReader->name];
                 // Call the setter method
                 $record->{$method}($this->xmlReader->readString());
             } elseif (isset($this->complexProperties[$this->xmlReader->name])) {
                 $this->setComplexProperty($record);
             } elseif (isset($this->complexPropertySets[$this->xmlReader->name])) {
                 $this->setComplexPropertySet($record);
             } else {
                 $this->otherElementEncountered($record);
             }
         }
     }
     return $record;
 }
开发者ID:georgeh,项目名称:php-beerxml,代码行数:31,代码来源:Record.php

示例2: processXml

 /**
  * @param  \XMLReader $xml an XML document to be transformed to GitHub Markdown
  * @return String
  */
 protected function processXml($xml)
 {
     $output = '';
     // states
     $inLink = false;
     /**
      * Mapping of elements which just append additional markup to the text
      */
     $appendersMap = [self::NODE_HR => '----', self::NODE_BR => "\n", self::NODE_H1 => 'h1. ', self::NODE_H2 => 'h2. ', self::NODE_H3 => 'h3. ', self::NODE_H4 => 'h4. ', self::NODE_H5 => 'h5. ', self::NODE_H6 => 'h6. ', self::NODE_BLOCKQUOTE => 'bq. '];
     /**
      * Mapping of elements which wrap text with additional markup
      */
     $wrappersMap = [self::NODE_EMPHASIZED => '_', self::NODE_STRONG => '*'];
     while ($xml->read()) {
         // if it's a beginning of new paragraph just continue
         if ($xml->nodeType === \XMLReader::ELEMENT && $xml->name === self::NODE_PARAGRAPH) {
             continue;
         }
         // if it's an ending of a paragraph add newlines
         if ($xml->nodeType === \XMLReader::END_ELEMENT && $xml->name === self::NODE_PARAGRAPH) {
             $output .= "\n\n";
         }
         // take care of wrapping nodes
         if (in_array($xml->name, array_keys($wrappersMap))) {
             $output .= $wrappersMap[$xml->name];
         }
         // take care of nodes which just append things to their text
         if (in_array($xml->name, array_keys($appendersMap)) && $xml->nodeType !== \XMLReader::END_ELEMENT) {
             $output .= $appendersMap[$xml->name];
         }
         // links
         if ($xml->name === self::NODE_A && $xml->nodeType !== \XMLReader::END_ELEMENT) {
             $output .= '[';
             $inLink = true;
         }
         if ($xml->name === self::NODE_A && $xml->nodeType === \XMLReader::END_ELEMENT) {
             $output .= $xml->getAttribute('href') . ']';
             $inLink = false;
         }
         // just add the text
         if ($xml->nodeType === \XMLReader::TEXT) {
             $text = $xml->readString();
             if ($inLink && !empty($text)) {
                 $output .= $text . '|';
             } else {
                 $output .= $text;
             }
         }
     }
     return trim($output);
 }
开发者ID:hackathoners,项目名称:markup-translator,代码行数:55,代码来源:Jira.php

示例3: scanContent

 /**
  * Scans conntent for cachedUntil and error
  *   
  * @param string $content
  * @param int $errorCode
  * @param string $errorText
  */
 protected function scanContent($content, &$errorCode, &$errorText)
 {
     $this->cachedUntil = null;
     $reader = new XMLReader();
     $reader->xml($content);
     while ($reader->read()) {
         if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "error") {
             // got an error
             $errorText = $reader->readString();
             $errorCode = intval($reader->getAttribute('code'));
             if ($reader->next("cachedUntil")) {
                 $this->cachedUntil = $reader->readString();
             }
         } else {
             if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "result") {
                 // no errors, we need to read the cache time though
                 if ($reader->next("cachedUntil")) {
                     $this->cachedUntil = $reader->readString();
                 }
             }
         }
     }
     $reader->close();
 }
开发者ID:ncrawford,项目名称:eve_contract_viewer,代码行数:31,代码来源:eveonline.php

示例4: parse

 public function parse(\XMLReader $xmlReader, $startingDepth = 0, $parseOne = false)
 {
     if ($this->callback !== null) {
         $node = new Node();
         $node->name = $xmlReader->name;
         $node->depth = $xmlReader->depth;
         $node->text = $xmlReader->readString();
         if ($xmlReader->hasAttributes && $xmlReader->moveToFirstAttribute()) {
             do {
                 $node->attributes[$xmlReader->name] = $xmlReader->value;
             } while ($xmlReader->moveToNextAttribute());
             $xmlReader->moveToElement();
         }
         $callback = $this->callback;
         $callback($this->processNode($node, $xmlReader));
     }
 }
开发者ID:rhubarbphp,项目名称:rhubarb,代码行数:17,代码来源:NodeStrategyRead.php

示例5: next

 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->valid = false;
     $style = null;
     $type = null;
     $columnIndex = null;
     $rowBuilder = null;
     $currentKey = 0;
     while ($this->xml->read()) {
         if (\XMLReader::ELEMENT === $this->xml->nodeType) {
             switch ($this->xml->name) {
                 case 'row':
                     $currentKey = (int) $this->xml->getAttribute('r');
                     $rowBuilder = $this->rowBuilderFactory->create();
                     break;
                 case 'c':
                     $columnIndex = $this->columnIndexTransformer->transform($this->xml->getAttribute('r'));
                     $style = $this->getValue($this->xml->getAttribute('s'));
                     $type = $this->getValue($this->xml->getAttribute('t'));
                     break;
                 case 'v':
                     $rowBuilder->addValue($columnIndex, $this->valueTransformer->transform($this->xml->readString(), $type, $style));
                     break;
                 case 'is':
                     $rowBuilder->addValue($columnIndex, $this->xml->readString());
                     break;
             }
         } elseif (\XMLReader::END_ELEMENT === $this->xml->nodeType) {
             switch ($this->xml->name) {
                 case 'row':
                     $currentValue = $rowBuilder->getData();
                     if (count($currentValue)) {
                         $this->currentKey = $currentKey;
                         $this->currentValue = $currentValue;
                         $this->valid = true;
                         return;
                     }
                     break;
                 case 'sheetData':
                     break 2;
             }
         }
     }
 }
开发者ID:xakepsoft,项目名称:spreadsheet-parser,代码行数:47,代码来源:RowIterator.php

示例6: testMoveToNextElement

 /**
  * Tests JFeedParser::moveToNextElement()
  *
  * @return  void
  *
  * @since   12.3
  */
 public function testMoveToNextElement()
 {
     // Set the XML for the internal reader and move the stream to the <root> element.
     $this->_reader->Xml('<root><node test="first"><child>foobar</child></node><node test="second"></node></root>');
     $this->_reader->next('root');
     // Ensure that the current node is "root".
     $this->assertEquals('root', $this->_reader->name);
     // Move to the next element, which should be <node test="first">.
     TestReflection::invoke($this->_instance, 'moveToNextElement');
     $this->assertEquals('node', $this->_reader->name);
     $this->assertEquals('first', $this->_reader->getAttribute('test'));
     // Move to the next element, which should be <child> with a data value of "foobar".
     TestReflection::invoke($this->_instance, 'moveToNextElement');
     $this->assertEquals('child', $this->_reader->name);
     $this->assertEquals('foobar', $this->_reader->readString());
     // Move to the next element, which should be <node test="second">.
     TestReflection::invoke($this->_instance, 'moveToNextElement');
     $this->assertEquals('node', $this->_reader->name);
     $this->assertEquals('second', $this->_reader->getAttribute('test'));
     // Move to the next element, which should be <node test="second">.
     $return = TestReflection::invoke($this->_instance, 'moveToNextElement');
     $this->assertFalse($return);
 }
开发者ID:n3t,项目名称:joomla-cms,代码行数:30,代码来源:JFeedParserTest.php

示例7: elementsFromXmlReader

 /**
  * Чтение элементов из \XMLReader
  * @param \XMLReader $xr
  */
 public function elementsFromXmlReader(\XMLReader &$xr)
 {
     switch ($xr->localName) {
         case "autouid":
             $this->setAutouid($xr->readString());
             break;
         case "ID":
             $this->setID($xr->readString());
             break;
         case "source":
             $this->setSource($xr->readString());
             break;
         case "destination":
             $this->setDestination($xr->readString());
             break;
         case "dtStart":
             $this->setDtStart($xr->readString());
             break;
         case "dtEnd":
             $this->setDtEnd($xr->readString());
             break;
         case "type":
             $this->setType($xr->readString());
             break;
         case "comments":
             $this->setComments($xr->readString());
             break;
         case "Ref":
             $Ref = \Adaptor_Bindings::create("\\Archive\\Port\\Adaptor\\Data\\Archive\\Refs\\Ref");
             $this->setRef($Ref->fromXmlReader($xr));
             break;
         default:
             parent::elementsFromXmlReader($xr);
     }
 }
开发者ID:servandserv,项目名称:sf,代码行数:39,代码来源:Link.php

示例8: elementsFromXmlReader

 /**
  * Чтение элементов из \XMLReader
  * @param \XMLReader $xr
  */
 public function elementsFromXmlReader(\XMLReader &$xr)
 {
     switch ($xr->localName) {
         case "x":
             $this->setX($xr->readString());
             break;
         case "y":
             $this->setY($xr->readString());
             break;
         case "width":
             $this->setWidth($xr->readString());
             break;
         case "height":
             $this->setHeight($xr->readString());
             break;
         case "Ref":
             $Ref = \Adaptor_Bindings::create("\\Archive\\Port\\Adaptor\\Data\\Archive\\Refs\\Ref");
             $this->setRef($Ref->fromXmlReader($xr));
             break;
         default:
             parent::elementsFromXmlReader($xr);
     }
 }
开发者ID:servandserv,项目名称:sf,代码行数:27,代码来源:Area.php

示例9: while

 while ($reader->read()) {
     if ($reader->nodeType == XMLREADER::ELEMENT && array_search($reader->name, $field_keys)) {
         $nodeName = $reader->name;
         $readThrough[] = $nodeName;
         if ($nodeName === "Author") {
             $authorIndex++;
         }
     }
     if ($reader->nodeType == XMLREADER::END_ELEMENT && array_search($reader->name, $field_keys)) {
         array_pop($readThrough);
         $nodeName = $readThrough[count($readThrough) - 1];
     }
     if ($reader->nodeType == XMLREADER::ELEMENT && count($readThrough) > 0) {
         if (in_array($reader->name, $fieldsArray[$nodeName])) {
             if ($nodeName === "PubDate") {
                 $record_data["pubDate"][$reader->name] = $reader->readString();
             }
             if ($nodeName === "DateCreated") {
                 $record_data["creationDate"][$reader->name] = $reader->readString();
             }
             if ($nodeName === "Author") {
                 $record_data["authorList"][$authorIndex][$reader->name] = $reader->readString();
             }
             if ($nodeName === "ArticleIdList") {
                 if ($reader->name === "ArticleId") {
                     $record_data["idList"][$reader->getAttribute("IdType")] = $reader->readString();
                 }
             }
             if (in_array($reader->name, array_keys($recordFields))) {
                 $record_data[$recordFields[$reader->name]] = $reader->readString();
             }
开发者ID:meggie10cn,项目名称:manifold-impact-analytics,代码行数:31,代码来源:search-response.php

示例10: getRecentSMS

 public function getRecentSMS()
 {
     $html = '';
     $json = '';
     $returnJSON = array();
     $returnJSON['SMS'] = array();
     // $params = $this->getBaseParams();
     $session = $this->getCurlGet($this->gvBaseURL . 'inbox/recent/sms?auth=' . $this->authToken);
     $result = curl_exec($session);
     // echo $result;
     $xml = new XMLReader();
     $xml->xml($result);
     $xml->read();
     if ($xml->name == 'response') {
         $xml->read();
         $xml->next('json');
         if ($xml->name == 'json') {
             $json = $xml->readString();
             $returnJSON['SMS']['data'] = json_decode($json, true);
         }
         $xml->next('html');
         // echo "name: " . $xml->name . " end";
         if ($xml->name == 'html') {
             // echo 'html: ' > $xml->readString();
             // echo "in HTML";
             // echo $xml->readString();
             $html = $xml->readString();
         }
     }
     $returnJSON['SMS']['data']['messagesByNumber'] = array();
     if (strlen($html) > 0) {
         $dom = new DOMDocument();
         // $smsData = array('conversations'=>array());
         if (@$dom->loadHTML($html)) {
             // echo $dom->saveHTML();
             $xpath = new DOMXPath($dom);
             $conversations = $xpath->query('//div[contains(@class, " gc-message ")]');
             $convo = array();
             // for ($citer = 0; $citer < $conversations->length; $citer++) {//$conversations as $conversation) {
             for ($citer = $conversations->length - 1; $citer >= 0; $citer--) {
                 $conversation = $conversations->item($citer);
                 // echo $entry->textContent . '<br>';
                 // echo $conversation->textContent;
                 $conversationID = $conversation->attributes->getNamedItem('id')->value;
                 $contactInfo = $xpath->query('div//a[contains(@class, "gc-message-name-link")]', $conversation);
                 $contactName = $contactInfo->item(0)->textContent;
                 $returnJSON['SMS']['data']['messages'][$conversationID]['contactName'] = $contactName;
                 $contactNumber = $returnJSON['SMS']['data']['messages'][$conversationID]['phoneNumber'];
                 if (!$returnJSON['SMS']['data']['messagesByNumber'][$contactNumber]) {
                     $returnJSON['SMS']['data']['messagesByNumber'][$contactNumber] = array();
                     $returnJSON['SMS']['data']['messagesByNumber'][$contactNumber]['meta'] = array('contactName' => $contactName, 'displayNumber' => $returnJSON['SMS']['data']['messages'][$conversationID]['displayNumber']);
                     $returnJSON['SMS']['data']['messagesByNumber'][$contactNumber]['messages'] = array();
                 }
                 $msgJSON = array('from' => 'TIME_CHANGE', 'text' => $returnJSON['SMS']['data']['messages'][$conversationID]['displayStartDateTime'], 'time' => '');
                 array_push($returnJSON['SMS']['data']['messagesByNumber'][$contactNumber]['messages'], $msgJSON);
                 $messages = $xpath->query('div//div[contains(@class, "gc-message-sms-row")]', $conversation);
                 for ($miter = 0; $miter < $messages->length; $miter++) {
                     // ($messages as $message) {
                     $message = $messages->item($miter);
                     $from = trim($message->childNodes->item(1)->textContent);
                     $text = $message->childNodes->item(3)->textContent;
                     $time = trim($message->childNodes->item(5)->textContent);
                     $messageJSON = array('from' => $from, 'text' => $text, 'time' => $time);
                     array_push($convo, $messageJSON);
                     array_push($returnJSON['SMS']['data']['messagesByNumber'][$contactNumber]['messages'], $messageJSON);
                     // echo "Message: " . $from . " " . $text . " " . $time . "<br>";
                 }
                 // echo "<br><br>";
                 // array_push($smsData['conversations'], $convo);
                 // echo $conversationID;
                 $returnJSON['SMS']['data']['messages'][$conversationID]['messages'] = $convo;
                 $convo = array();
             }
             // $returnJSON['SMS']['data'] = $smsData;
         }
     }
     return json_encode($returnJSON);
 }
开发者ID:adinardi,项目名称:voiceconnectr,代码行数:78,代码来源:gvClient.php

示例11: parse

 /**
  * Function for parsing XML file of repository
  * 
  * This function parses XML file and updates database used for searching. 
  * @param string last modified date
  * @param string URL of OL repository
  */
 function parse($date, $urlforrepo, $baseurl)
 {
     //create object of class XMLReader for reading XML file
     $xml = new XMLReader();
     //Parsing may take a few minutes because OL repository is quite large.
     @set_time_limit(0);
     global $db;
     //open XML file
     $xml->open($urlforrepo . "&from=" . $date . "T00:00:00Z");
     //$xml->open("oai2.php.xml");
     $members = array();
     //main array which will contain all entries of repo.
     $flag = false;
     $resumption = 'dummy';
     //resumption token of repository
     //parse while resumption token is not null.
     while ($resumption != '') {
         if ($resumption == 'dummy') {
             $xml->open($urlforrepo . "&from=" . $date . "T00:00:00Z");
             $resumption = '';
         } else {
             $xml->open($baseurl . 'verb=ListRecords&resumptionToken=' . $resumption);
         }
         //main logic starts
         while ($xml->read()) {
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'error') {
                 //error in parsing
                 $resumption = '';
             }
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'record') {
                 //starting of a new record
                 $member = array();
                 $flag = false;
                 //$member['uni']='';
             }
             //starting tag of identifier
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'identifier' && !isset($member['identifier'])) {
                 $member['identifier'] = addslashes(trim($xml->readString()));
             }
             //starting tag of datestamp
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'datestamp' && !isset($member['datestamp'])) {
                 $member['datestamp'] = addslashes(trim($xml->readString()));
             }
             //starting tag of entry
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'entry' && !isset($member['entry'])) {
                 $member['entry'] = trim($xml->readString());
             }
             //starting tag of catalog
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'catalog' && !isset($member['catalog'])) {
                 $member['catalog'] = addslashes(trim($xml->readString()));
             }
             //starting tag of description
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'description' && !isset($member['description'])) {
                 $tag1 = '';
                 while ($tag1 != 'title') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['title'] = addslashes(trim($xml->readString()));
                 while ($tag1 != 'description') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['description'] = addslashes(trim($xml->readString()));
                 $member['keywords'] = '';
             }
             //starting tag of keyword
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'keyword' && !$flag) {
                 $member['keywords'] .= addslashes(trim($xml->readString())) . ", ";
             }
             if ($xml->nodeType == XMLReader::END_ELEMENT && $xml->localName == 'general') {
                 $flag = true;
                 rtrim($member['keywords']);
                 $member['keywords'] = substr($member['keywords'], 0, strlen($member['keywords']) - 2);
             }
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'manifestation') {
                 $data = $xml->readString();
                 $tag = '';
                 if (strpos($data, 'web site') > 0) {
                     //echo 'case 1<br/>';
                     while ($tag != 'location') {
                         $xml->read();
                         $tag = $xml->localName;
                     }
                     $member['website'] = trim($xml->readString());
                 } else {
                     if (strpos($data, 'Common Cartridge') > 0) {
                         //echo 'case 2<br/>';
                         while ($tag != 'location') {
                             $xml->read();
                             $tag = $xml->localName;
                         }
                         $member['common'] = trim($xml->readString());
//.........这里部分代码省略.........
开发者ID:herat,项目名称:OpenLearn-Module-for-ATutor,代码行数:101,代码来源:update.class.php

示例12: testXXE_setParserProperty_SUBST_ENTITIES_disable_entity_loader

 /**
 * * @expectedException PHPUnit_Framework_Error
 * XMLReader::read(): I/O warning : failed to load
 external entity "file:///C:/Christopher_Spaeth/code/xml_files_windows/xxe.txt"
 */
 public function testXXE_setParserProperty_SUBST_ENTITIES_disable_entity_loader()
 {
     $xml = new XMLReader();
     // use setParserProperty
     $xml->open("../../xml_files_windows/xxe/xxe.xml");
     $xml->setParserProperty(XMLReader::SUBST_ENTITIES, true);
     libxml_disable_entity_loader(true);
     while ($xml->read()) {
         if ($xml->nodeType == XMLReader::ELEMENT && $xml->name == 'data') {
             $node = $xml->name;
             $content = $xml->readString();
         }
     }
     $content = preg_replace('/\\s+/', '', $content);
     $this->assertEquals("", $content);
 }
开发者ID:RUB-NDS,项目名称:DTD-Attacks,代码行数:21,代码来源:testXMLReader.php

示例13: elementsFromXmlReader

 /**
  * Чтение элементов из \XMLReader
  * @param \XMLReader $xr
  */
 public function elementsFromXmlReader(\XMLReader &$xr)
 {
     switch ($xr->localName) {
         case "id":
             $this->setId($xr->readString());
             break;
         case "userId":
             $this->setUserId($xr->readString());
             break;
         case "code":
             $this->setCode($xr->readString());
             break;
         case "word":
             $this->setWord($xr->readString());
             break;
         case "cAttempts":
             $this->setCAttempts($xr->readString());
             break;
         case "tAttempts":
             $this->setTAttempts($xr->readString());
             break;
         case "fAttempts":
             $this->setFAttempts($xr->readString());
             break;
         case "status":
             $this->setStatus($xr->readString());
             break;
         case "lastmod":
             $this->setLastmod($xr->readString());
             break;
         default:
             parent::elementsFromXmlReader($xr);
     }
 }
开发者ID:servandserv,项目名称:lexicon,代码行数:38,代码来源:Word.php

示例14: elementsFromXmlReader

 /**
  * Чтение элементов из \XMLReader
  * @param \XMLReader $xr
  */
 public function elementsFromXmlReader(\XMLReader &$xr)
 {
     switch ($xr->localName) {
         case "id":
             $this->setId($xr->readString());
             break;
         case "firstName":
             $this->setFirstName($xr->readString());
             break;
         case "email":
             $this->setEmail($xr->readString());
             break;
         case "gender":
             $this->setGender($xr->readString());
             break;
         case "lastName":
             $this->setLastName($xr->readString());
             break;
         case "link":
             $this->setLink($xr->readString());
             break;
         case "locale":
             $this->setLocale($xr->readString());
             break;
         case "name":
             $this->setName($xr->readString());
             break;
         case "timezone":
             $this->setTimezone($xr->readString());
             break;
         case "updatedTime":
             $this->setUpdatedTime($xr->readString());
             break;
         case "verified":
             $this->setVerified($xr->readString());
             break;
         default:
             parent::elementsFromXmlReader($xr);
     }
 }
开发者ID:servandserv,项目名称:lexicon,代码行数:44,代码来源:User.php

示例15: parse

 /**
  * Function for parsing XML file of repository
  * 
  * This function parses XML file and creates initial database used for searching. 
  * It may work on both online and offline modes. If internet connection is not
  * available then XML file attached in the module is used.
  *
  */
 function parse()
 {
     //create object of class XMLReader for reading XML file
     $xml = new XMLReader();
     //Parsing may take a few minutes because OL repository is quite large.
     @set_time_limit(0);
     global $db;
     $connS = false;
     //Find internet connection's status
     $conn = checkConnection();
     $op = '';
     if ($conn) {
         //internet connection is available so we can directly parse using URL
         $connS = true;
         $xml->open("http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_ilox");
         $op = '1';
     } else {
         $connS = false;
         //internet connection is unavailable so we need to use repository's offline version
         $xml->open("../../ol_search_open_learn/oai2.php.xml");
         $op = '2';
     }
     $members = array();
     //main array which will contain all entries of repo.
     $flag = false;
     $resumption = 'dummy';
     //resumption token of repository
     //parse while resumption token is not null.
     while ($resumption != '') {
         if ($resumption == 'dummy' && $connS) {
             //if this is first iteration then use following URL
             $xml->open('http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_ilox');
             $resumption = '';
         } else {
             if ($connS) {
                 //if this is not first URL then use resumption token of last page
                 $xml->open('http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&resumptionToken=' . $resumption);
             }
         }
         //main logic of parsing
         while ($xml->read()) {
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'record') {
                 //starting of a new record
                 $member = array();
                 $flag = false;
                 //$member['uni']='';
             }
             //starting tag of identifier
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'identifier' && !isset($member['identifier'])) {
                 $member['identifier'] = addslashes(trim($xml->readString()));
             }
             //starting tag of datestamp
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'datestamp' && !isset($member['datestamp'])) {
                 $member['datestamp'] = addslashes(trim($xml->readString()));
             }
             //starting tag of entry
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'entry' && !isset($member['entry'])) {
                 $member['entry'] = trim($xml->readString());
             }
             //starting tag of catalog
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'catalog' && !isset($member['catalog'])) {
                 $member['catalog'] = addslashes(trim($xml->readString()));
             }
             //starting tag of description
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'description' && !isset($member['description'])) {
                 $tag1 = '';
                 while ($tag1 != 'title') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['title'] = addslashes(trim($xml->readString()));
                 while ($tag1 != 'description') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['description'] = addslashes(trim($xml->readString()));
                 $member['keywords'] = '';
             }
             //starting tag of keywords
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'keyword' && !$flag) {
                 $member['keywords'] .= addslashes(trim($xml->readString())) . ", ";
             }
             if ($xml->nodeType == XMLReader::END_ELEMENT && $xml->localName == 'general') {
                 $flag = true;
                 rtrim($member['keywords']);
                 $member['keywords'] = substr($member['keywords'], 0, strlen($member['keywords']) - 2);
             }
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'manifestation') {
                 $data = $xml->readString();
                 $tag = '';
                 if (strpos($data, 'web site') > 0) {
                     //echo 'case 1<br/>';
//.........这里部分代码省略.........
开发者ID:herat,项目名称:OpenLearn-Module-for-ATutor,代码行数:101,代码来源:parse.class.php


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