示例#1
3
 public function start_process()
 {
     if (!$this->path_to_xml_file) {
         return false;
     }
     if (!$this->valid_xml) {
         return false;
     }
     $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => DOC_ROOT . 'temp/xml_to_archive/'));
     $this->taxon_ids = array();
     $this->media_ids = array();
     $this->vernacular_name_ids = array();
     $this->reference_ids = array();
     $this->agent_ids = array();
     $reader = new \XMLReader();
     $file = file_get_contents($this->path_to_xml_file);
     $file = iconv("UTF-8", "UTF-8//IGNORE", $file);
     $reader->XML($file);
     $i = 0;
     while (@$reader->read()) {
         if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "taxon") {
             $taxon_xml = $reader->readOuterXML();
             $t = simplexml_load_string($taxon_xml, null, LIBXML_NOCDATA);
             if ($t) {
                 $this->add_taxon_to_archive($t);
             }
             $i++;
             if ($i % 100 == 0) {
                 echo "Parsed taxon {$i} : " . time_elapsed() . "\n";
             }
             // if($i >= 5000) break;
         }
     }
     $this->archive_builder->finalize();
 }
示例#2
0
文件: XmlTrim.php 项目: shevron/stoa
 public function filter($value)
 {
     $this->_initReaderWriter();
     $this->_reader->XML($value);
     $this->_doXmlTrim();
     $this->_writer->endDocument();
     return $this->_writer->outputMemory();
 }
示例#3
0
 /**
  * @param string $xml
  */
 public function __construct($xml)
 {
     $this->xml = new XMLReader();
     if (preg_match('/^<\\?xml/', trim($xml))) {
         $this->xml->XML($xml);
     } else {
         $this->xml->open($xml);
     }
     $this->parse();
 }
 /**
  * Constructor
  *
  * Creates an SVGReader drawing from the source provided
  * @param string $source URI from which to read
  * @throws MWException|Exception
  */
 function __construct($source)
 {
     global $wgSVGMetadataCutoff;
     $this->reader = new XMLReader();
     // Don't use $file->getSize() since file object passed to SVGHandler::getMetadata is bogus.
     $size = filesize($source);
     if ($size === false) {
         throw new MWException("Error getting filesize of SVG.");
     }
     if ($size > $wgSVGMetadataCutoff) {
         $this->debug("SVG is {$size} bytes, which is bigger than {$wgSVGMetadataCutoff}. Truncating.");
         $contents = file_get_contents($source, false, null, -1, $wgSVGMetadataCutoff);
         if ($contents === false) {
             throw new MWException('Error reading SVG file.');
         }
         $this->reader->XML($contents, null, LIBXML_NOERROR | LIBXML_NOWARNING);
     } else {
         $this->reader->open($source, null, LIBXML_NOERROR | LIBXML_NOWARNING);
     }
     // Expand entities, since Adobe Illustrator uses them for xmlns
     // attributes (bug 31719). Note that libxml2 has some protection
     // against large recursive entity expansions so this is not as
     // insecure as it might appear to be. However, it is still extremely
     // insecure. It's necessary to wrap any read() calls with
     // libxml_disable_entity_loader() to avoid arbitrary local file
     // inclusion, or even arbitrary code execution if the expect
     // extension is installed (bug 46859).
     $oldDisable = libxml_disable_entity_loader(true);
     $this->reader->setParserProperty(XMLReader::SUBST_ENTITIES, true);
     $this->metadata['width'] = self::DEFAULT_WIDTH;
     $this->metadata['height'] = self::DEFAULT_HEIGHT;
     // The size in the units specified by the SVG file
     // (for the metadata box)
     // Per the SVG spec, if unspecified, default to '100%'
     $this->metadata['originalWidth'] = '100%';
     $this->metadata['originalHeight'] = '100%';
     // Because we cut off the end of the svg making an invalid one. Complicated
     // try catch thing to make sure warnings get restored. Seems like there should
     // be a better way.
     MediaWiki\suppressWarnings();
     try {
         $this->read();
     } catch (Exception $e) {
         // Note, if this happens, the width/height will be taken to be 0x0.
         // Should we consider it the default 512x512 instead?
         MediaWiki\restoreWarnings();
         libxml_disable_entity_loader($oldDisable);
         throw $e;
     }
     MediaWiki\restoreWarnings();
     libxml_disable_entity_loader($oldDisable);
 }
 public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
 {
     $this->succeed = FALSE;
     $xmlReader = new \XMLReader();
     try {
         $xmlReader->XML($content);
         $result = XMLParser::parseNormalError($xmlReader);
         if ($result['Code'] == Constants::QUEUE_NOT_EXIST) {
             throw new QueueNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
         }
         if ($result['Code'] == Constants::MESSAGE_NOT_EXIST) {
             throw new MessageNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
         }
         throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
     } catch (\Exception $e) {
         if ($exception != NULL) {
             throw $exception;
         } elseif ($e instanceof MnsException) {
             throw $e;
         } else {
             throw new MnsException($statusCode, $e->getMessage());
         }
     } catch (\Throwable $t) {
         throw new MnsException($statusCode, $t->getMessage());
     }
 }
示例#6
0
 /**
  * Tests JFeedParser::moveToClosingElement() with self-closing tags.
  *
  * @return  void
  *
  * @since   12.3
  */
 public function testMoveToClosingElementWithSelfClosingTag()
 {
     // Set the XML for the internal reader and move the stream to the first <node> element.
     $this->_reader->XML('<root><node test="first" /><node test="second"></node></root>');
     // Advance the reader to the first <node> element.
     do {
         $this->_reader->read();
     } while ($this->_reader->name != 'node');
     // Ensure that the current node is <node test="first">.
     $this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType);
     $this->assertEquals('node', $this->_reader->name);
     $this->assertEquals('first', $this->_reader->getAttribute('test'));
     // Move to the closing element, which should be </node>.
     TestReflection::invoke($this->_instance, 'moveToClosingElement');
     $this->assertEquals(true, $this->_reader->isEmptyElement);
     $this->assertEquals('node', $this->_reader->name);
     // Advance the reader to the next element.
     do {
         $this->_reader->read();
     } while ($this->_reader->nodeType != XMLReader::ELEMENT);
     // Ensure that the current node is <node test="first">.
     $this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType);
     $this->assertEquals('node', $this->_reader->name);
     $this->assertEquals('second', $this->_reader->getAttribute('test'));
 }
 public static function &buildTree($source, $mode = XMLDocument::BUILD_MODE_FROM_FILE, $ns = NULL)
 {
     if ($mode == XMLDocument::BUILD_MODE_FROM_FILE) {
         if (($content = Filesystem::getFileContent($source)) === NULL) {
             return NULL;
         }
     } else {
         if ($source == "" || $source == NULL) {
             return new xmlTree();
         }
         $content = $ns == NULL ? "<ROOT>" . $source . "</ROOT>" : "<ROOT xmlns:{$ns}=\".\">" . $source . "</ROOT>";
     }
     /*$content = ereg_replace( "&amp;", "&", $content );
     		$content = ereg_replace( "&", "&amp;", $content );*/
     //echo $content;
     $content = preg_replace("/&amp;/", "&", $content);
     $content = preg_replace("/&/", "&amp;", $content);
     $content = iconv("windows-1251", "UTF-8", $content);
     $reader = new XMLReader();
     if ($reader->XML($content)) {
         $_docTree = NULL;
         $_docTree = new xmlTree();
         self::_appendChilds($_docTree->getCurrent(), $reader, 0);
         $reader = NULL;
         return $_docTree;
     } else {
         self::raiseException(ERR_XML_INVALID_XML, $content);
         return NULL;
     }
 }
示例#8
0
 private static function testXml()
 {
     $xml = new \XMLReader();
     $xml->XML(self::$TestXml);
     $xmlarray = xmlWithArray::xmlToarray($xml);
     return $xmlarray;
 }
 public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
 {
     $this->succeed = FALSE;
     $xmlReader = new \XMLReader();
     try {
         $xmlReader->XML($content);
         $result = XMLParser::parseNormalError($xmlReader);
         if ($result['Code'] == Constants::TOPIC_NOT_EXIST) {
             throw new TopicNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
         }
         if ($result['Code'] == Constants::INVALID_ARGUMENT) {
             throw new InvalidArgumentException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
         }
         if ($result['Code'] == Constants::MALFORMED_XML) {
             throw new MalformedXMLException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
         }
         throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
     } catch (\Exception $e) {
         if ($exception != NULL) {
             throw $exception;
         } elseif ($e instanceof MnsException) {
             throw $e;
         } else {
             throw new MnsException($statusCode, $e->getMessage());
         }
     } catch (\Throwable $t) {
         throw new MnsException($statusCode, $t->getMessage());
     }
 }
 public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
 {
     $this->succeed = FALSE;
     $xmlReader = new \XMLReader();
     try {
         $xmlReader->XML($content);
         while ($xmlReader->read()) {
             if ($xmlReader->nodeType == \XMLReader::ELEMENT) {
                 switch ($xmlReader->name) {
                     case Constants::ERROR:
                         $this->parseNormalErrorResponse($xmlReader);
                         break;
                     default:
                         // case Constants::Messages
                         $this->parseBatchSendErrorResponse($xmlReader);
                         break;
                 }
             }
         }
     } catch (\Exception $e) {
         if ($exception != NULL) {
             throw $exception;
         } elseif ($e instanceof MnsException) {
             throw $e;
         } else {
             throw new MnsException($statusCode, $e->getMessage());
         }
     } catch (\Throwable $t) {
         throw new MnsException($statusCode, $t->getMessage());
     }
 }
示例#11
0
 /**
  * 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;
 }
示例#12
0
 /**
  * Проверка по схеме
  */
 public function validate($schemaPath)
 {
     $xr = new XMLReader();
     $xr->XML($this->toXmlStr());
     $xr->setSchema($schemaPath);
     while ($xr->read()) {
     }
 }
示例#13
0
 protected function loadXmlContent($content)
 {
     $xmlReader = new \XMLReader();
     $isXml = $xmlReader->XML($content);
     if ($isXml === FALSE) {
         throw new MnsException($statusCode, $content);
     }
     return $xmlReader;
 }
示例#14
0
/**
 * Process the XML query
 * @param $xmltext the provided XML
 */
function processXml($xmltext)
{
    // Load the XML
    $xml = new XMLReader();
    if (!$xml->XML($xmltext)) {
        echo '<hatter status="no" msg="invalid XML" />';
        exit;
    }
    // Connect to the database
    $pdo = pdo_connect();
    // Read to the start tag
    while ($xml->read()) {
        if ($xml->nodeType == XMLReader::ELEMENT && $xml->name == "hatter") {
            // We have the hatter tag
            $magic = $xml->getAttribute("magic");
            if ($magic != "NechAtHa6RuzeR8x") {
                echo '<hatter status="no" msg="magic" />';
                exit;
            }
            $user = $xml->getAttribute("user");
            $password = $xml->getAttribute("pw");
            $userid = getUser($pdo, $user, $password);
            // Read to the hatting tag
            while ($xml->read()) {
                if ($xml->nodeType == XMLReader::ELEMENT && $xml->name == "hatting") {
                    $name = $xml->getAttribute("name");
                    $uri = $xml->getAttribute("uri");
                    $x = $xml->getAttribute("x");
                    $y = $xml->getAttribute("y");
                    $angle = $xml->getAttribute("angle");
                    $scale = $xml->getAttribute("scale");
                    $color = $xml->getAttribute("color");
                    $hat = $xml->getAttribute("hat");
                    $feather = $xml->getAttribute("feather") == "yes" ? 1 : 0;
                    $nameQ = $pdo->quote($name);
                    $uriQ = $pdo->quote($uri);
                    // Checks
                    if (!is_numeric($x) || !is_numeric($y) || !is_numeric($angle) || !is_numeric($scale) || !is_numeric($color) || !is_numeric($hat)) {
                        echo '<hatter status="no" msg="invalid" />';
                        exit;
                    }
                    $query = <<<QUERY
REPLACE INTO hatting(name, userid, uri, type, x, y, rotation, scale, color, feather)
VALUES({$nameQ}, '{$userid}', {$uriQ}, {$hat}, {$x}, {$y}, {$angle}, {$scale}, {$color}, {$feather})
QUERY;
                    if (!$pdo->query($query)) {
                        echo '<hatter status="no" msg="insertfail">' . $query . '</hatter>';
                        exit;
                    }
                    echo '<hatter status="yes"/>';
                    exit;
                }
            }
        }
    }
    echo '<hatter save="no" msg="invalid XML" />';
}
示例#15
0
 public function XML($source, $encoding = NULL, $options = 0)
 {
     if (!@parent::XML($source, $encoding, $options | LIBXML_NONET | LIBXML_NOENT)) {
         if (false !== ($error = libxml_get_last_error())) {
             libxml_clear_errors();
             $ex = new XmlParseException('Unable to open XML stream from given XML source');
             $ex->addError(new XmlError($error->level, $error->message));
             throw $ex;
         }
         throw new XmlParseException('Unable to open XML stream from given XML source');
     }
     return true;
 }
示例#16
0
 /**
  * Method for loading XML Data from String
  *
  * @param string $sXml
  * @param bool $bOptimize
  */
 public static function parseString($sXml, $bOptimize = false)
 {
     $oXml = new XMLReader();
     $this->bOptimize = (bool) $bOptimize;
     try {
         // Set String Containing XML data
         $oXml->XML($sXml);
         // Parse Xml and return result
         return self::parseXml($oXml, $bOptimize);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
 /**
  * Tests JFeedParserRss::initialise()
  *
  * @param   string  $expected  The expected rss version string.
  * @param   string  $xml       The XML string for which to detect the version.
  *
  * @return  void
  *
  * @since   3.0
  *
  * @covers  JFeedParserRss::initialise
  * @dataProvider  seedInitialise
  */
 public function testInitialise($expected, $xml)
 {
     // Set the XML for the internal reader.
     $this->reader->XML($xml);
     // Advance the reader to the first element.
     while ($this->reader->read() && $this->reader->nodeType != XMLReader::ELEMENT) {
     }
     TestReflection::invoke($this->object, 'initialise');
     $this->assertAttributeEquals($expected, 'version', $this->object, 'The version string detected should match the expected value.');
     // Verify that after detecting the version we are ready to start parsing.
     $this->assertEquals('test', $this->reader->name);
     $this->assertEquals(XMLReader::ELEMENT, $this->reader->nodeType);
 }
 /**
  * @param  string $response
  * @return array
  */
 public static function convert($response)
 {
     $xml = new \XMLReader();
     if ($xml->XML($response, null, LIBXML_DTDVALID)) {
         $xmlList = simplexml_load_string($response);
         $data = array();
         foreach ($xmlList as $element) {
             static::convertXmlObjToArr($element, $data);
         }
         return $data;
     } else {
         return $response;
     }
 }
示例#19
0
文件: saikyo.php 项目: mkrdip/lijobs
 private function getReader($feed)
 {
     $reader = new XMLReader();
     $open = (int) ini_get('allow_url_fopen');
     if ($open) {
         $result = $reader->open($feed->url);
     } else {
         $result = $this->curl_open($feed->url);
         if ($result) {
             $reader->XML($result);
         }
     }
     return $result ? $reader : false;
 }
示例#20
0
 /**
  * @param bool $asString - true - return xml as string, false - return as Gedcomx object
  * @return Gedcomx|null|string - null when there are no more records
  */
 public function nextRecord($asString)
 {
     $xmlReader = $this->xmlReader;
     if ($xmlReader->name !== self::RECORD_NODE_NAME) {
         return null;
     }
     $record = $xmlReader->readOuterXml();
     $xmlReader->next(self::RECORD_NODE_NAME);
     if (!$asString) {
         $tempXmlReader = new \XMLReader();
         $tempXmlReader->XML($record);
         $record = new Gedcomx($tempXmlReader);
     }
     return $record;
 }
 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;
 }
示例#22
0
 /**
  * Parse XML formatted string into config data
  * @param string $data
  * @param IDataGroup $group
  * @return IDataGroup
  */
 public static function convert($data, IDataGroup $group = null)
 {
     if (!$group) {
         $group = new DataGroup();
     }
     /** @var XMLReader */
     $reader = new XMLReader();
     $reader->XML($data, 'utf-8', LIBXML_NOBLANKS | LIBXML_NOCDATA);
     do {
         $reader->read();
     } while ($reader->nodeType != XMLReader::ELEMENT);
     if ($reader->nodeType == XMLReader::ELEMENT) {
         self::parseInternal($reader, $group);
     }
     return $group;
 }
示例#23
0
 public function parse($subject)
 {
     $classes = new IoCClasses();
     $xmlReader = new XMLReader();
     $xmlReader->XML($subject);
     $xmlReader->setSchema(dirname(__FILE__) . '/xmlValidator.xsd');
     while ($xmlReader->read()) {
         if ($xmlReader->nodeType == XMLReader::ELEMENT) {
             while ($xmlReader->name == 'classes') {
                 $classes->merge($this->readIoCStructure($xmlReader));
                 $xmlReader->next();
             }
         }
     }
     $xmlReader->close();
     return $classes;
 }
示例#24
0
 public function __construct($xml, $version, $url)
 {
     if (false) {
         echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br/>';
         echo str_replace('<', '&lt;', $xml) . '<br>';
         echo '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<br/>';
     }
     $this->version = $version;
     $url = parse_url($url);
     $this->baseApiUrl = $url['scheme'] . '://' . $url['host'] . ($url['port'] ? ':' . $url['port'] : '');
     $xmlReader = new XMLReader();
     $xmlReader->XML($xml);
     while ($xmlReader->read()) {
         if ($xmlReader->nodeType == XMLReader::ELEMENT && $xmlReader->localName == "Answer") {
             $this->answer = $this->parseAnswer($xmlReader);
         }
     }
 }
 /**
  * Parses the contents of a given file.
  *
  * @param $filePath
  * @throws Exceptions\FileReaderException
  * @return array
  */
 public static function parse($filePath)
 {
     try {
         $data = self::load($filePath);
         if (!empty($data)) {
             $xml = new \XMLReader();
             if ($xml->XML($data, NULL, LIBXML_DTDVALID)) {
                 //This will convert XML to an array, losing XML attributes in all tags.
                 $data = simplexml_load_string($data);
                 settype($data, 'array');
                 return json_decode(json_encode($data), true);
             } else {
                 throw new FileReaderException('The file does not contain valid well formatted XML data.');
             }
         } else {
             throw new FileReaderException('No data has been loaded. Use the load($filePath) method before using getData().');
         }
     } catch (FileReaderException $e) {
         throw new FileReaderException($e);
     }
 }
 /**
  * @test
  */
 public function aSingleNodeExportedWithNodeDataExportCanBeImportedWithNodeDataImport()
 {
     $originalNode = $this->rootNode->createNode('foo', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:ImportExport'));
     $originalNode->setProperty('description', 'Some node with a property');
     $originalNode->setProperty('someDate', new \DateTime());
     $this->persistenceManager->persistAll();
     $exportService = new NodeExportService();
     $xml = $exportService->export('/')->outputMemory();
     $this->nodeDataRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->saveNodesAndTearDownRootNodeAndRepository();
     $this->setUpRootNodeAndRepository();
     $importService = new NodeImportService();
     $reader = new \XMLReader();
     $reader->XML($xml);
     $importService->import($reader, '/');
     $importedNode = $this->rootNode->getNode('foo');
     $this->assertNotNull($importedNode, 'Expected node not found');
     $this->assertSame($originalNode->getIdentifier(), $importedNode->getIdentifier());
     $this->assertSame($originalNode->getProperty('description'), $importedNode->getProperty('description'));
     $this->assertEquals($originalNode->getProperty('someDate'), $importedNode->getProperty('someDate'));
 }
 /**
  * Parse the response from an OAI query into an array.
  * This method returns an associative array with two keys
  * <ul>
  * <li><em>token</em> => the resumption token</li>
  * <li><em>items</em> => an array of items, each being an associative array with a single key called uri</li>
  * </ul>
  * @param string xml the OAI response as an XML document
  * @return array
  */
 function parse_oai_xml($xml)
 {
     $res = array();
     $reader = new XMLReader();
     $reader->XML($xml);
     $items = array();
     $item = array();
     $status = 'seeking_header';
     while ($reader->read()) {
         if ($reader->nodeType == XMLReader::ELEMENT) {
             if ($reader->name == 'header') {
                 $status = 'seeking_identifier';
             } elseif ($reader->name == 'identifier' && $status == 'seeking_identifier') {
                 $status = 'reading_identifier';
             } elseif ($reader->name == 'datestamp' && $status == 'seeking_datestamp') {
                 $status = 'reading_datestamp';
             } elseif ($reader->name == 'resumptionToken') {
                 $status = 'reading_token';
                 $res['entities_count'] = $reader->getAttribute('completeListSize');
             }
         } elseif ($reader->nodeType == XMLReader::TEXT) {
             if ($status == 'reading_identifier') {
                 $item = array('uri' => $reader->value);
                 $status = 'seeking_datestamp';
             } elseif ($status == 'reading_datestamp') {
                 $item['datestamp'] = $reader->value;
                 $items[] = $item;
                 $status = 'seeking_header';
             } elseif ($status == 'reading_token') {
                 $res['token'] = $reader->value;
                 $status = 'seeking_header';
             }
         }
     }
     $reader->close();
     $res['items'] = $items;
     return $res;
 }
示例#28
0
 /**
  * 
  * @param string $issueDataXml
  * @return string the xsi:null value
  */
 private function readDueDate($issueDataXml)
 {
     $reader = new XMLReader();
     $reader->XML($this->client->__getLastResponse());
     while ($reader->read()) {
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 if ($reader->name == 'due_date') {
                     return $reader->getAttribute('xsi:nil');
                 }
                 break;
         }
     }
     return null;
 }
 /**
  * Parses through xml and looks for the 'cookie' parameter
  * @param string $xml the xml to parse through
  * @return string $sessoin returns the session id
  */
 public function read_cookie_xml($xml = '')
 {
     global $CFG, $USER, $COURSE;
     if (empty($xml)) {
         if (is_siteadmin($USER->id)) {
             notice(get_string('adminemptyxml', 'adobeconnect'), $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
         } else {
             notice(get_string('emptyxml', 'adobeconnect'), '', $COURSE);
         }
     }
     $session = false;
     //            $accountid = false;
     $reader = new XMLReader();
     $reader->XML($xml, 'UTF-8');
     while ($reader->read()) {
         if (0 == strcmp($reader->name, 'cookie')) {
             if (1 == $reader->nodeType) {
                 $session = $reader->readString();
             }
         }
     }
     $reader->close();
     $this->_cookie = $session;
     return $session;
 }
 /**
  * Parse XML content and convert it to PHP array
  * 
  * @return void
  */
 private function parseXML()
 {
     $xml = new XMLReader();
     $headers = array();
     $data = array();
     $typevar = '';
     $varname = '';
     $varvalue = '';
     $countvar = 0;
     $itemname = '';
     $xml->XML($this->getXMLContent(), 'UTF8');
     while ($xml->read()) {
         if ($xml->name == 'sgc' && $xml->nodeType == XMLReader::ELEMENT) {
             $headers['version'] = $xml->getAttribute('version');
             $headers['scopename'] = $xml->getAttribute('scopename');
             while ($xml->read()) {
                 if ($xml->name == 'headers' && $xml->nodeType == XMLReader::ELEMENT) {
                     while ($xml->read()) {
                         if ($xml->name == 'datatype' && $xml->nodeType == XMLReader::ELEMENT) {
                             $headers['datatype'] = $xml->getAttribute('type');
                         }
                         if ($xml->name == 'component' && $xml->nodeType == XMLReader::ELEMENT) {
                             $xml->read();
                             if ($xml->hasValue) {
                                 $headers['component'] = $xml->value;
                             } else {
                                 $headers['component'] = '';
                             }
                         }
                         if ($xml->name == 'description' && $xml->nodeType == XMLReader::ELEMENT) {
                             $xml->read();
                             if ($xml->hasValue) {
                                 $headers['description'] = $xml->value;
                             } else {
                                 $headers['description'] = '';
                             }
                             break;
                         }
                     }
                 }
                 if ($xml->name == 'envelope' && $xml->nodeType == XMLReader::ELEMENT) {
                     while ($xml->read()) {
                         if ($xml->name == 'datas' && $xml->nodeType == XMLReader::ELEMENT) {
                             while ($xml->read()) {
                                 if ($xml->name == 'data' && $xml->nodeType == XMLReader::ELEMENT) {
                                     $typevar = $xml->getAttribute('type');
                                     $isnull = $xml->getAttribute('isnull');
                                     while ($xml->read()) {
                                         if ($xml->name == $typevar && $xml->nodeType == XMLReader::ELEMENT) {
                                             switch ($typevar) {
                                                 case 'array':
                                                     $varname = $xml->getAttribute('name');
                                                     $countvar = $xml->getAttribute('count');
                                                     $i = 0;
                                                     $data[$varname] = array();
                                                     while ($xml->read()) {
                                                         if ($xml->name == 'items' && $xml->nodeType == XMLReader::ELEMENT) {
                                                             while ($xml->read()) {
                                                                 if ($xml->name == 'item' && $xml->nodeType == XMLReader::ELEMENT) {
                                                                     $itemname = $xml->getAttribute('name');
                                                                     $xml->read();
                                                                     if ($xml->hasValue) {
                                                                         $varvalue = $xml->value;
                                                                     } else {
                                                                         $varvalue = '';
                                                                     }
                                                                     $data[$varname][$itemname] = $varvalue;
                                                                     if ($i != $countvar - 1) {
                                                                         $i++;
                                                                     } else {
                                                                         break;
                                                                     }
                                                                 }
                                                             }
                                                             break;
                                                         }
                                                     }
                                                     break;
                                                 case 'string':
                                                     $varname = $xml->getAttribute('name');
                                                     $xml->read();
                                                     if ($xml->hasValue) {
                                                         $varvalue = $xml->value;
                                                     } else {
                                                         $varvalue = '';
                                                     }
                                                     $data[$varname] = $varvalue;
                                                     break;
                                             }
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $xml->close();
     $this->setData($data);
     $this->setHeaders($headers);
 }