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


PHP DOMDocument::schemaValidateSource方法代码示例

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


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

示例1: isValid

 public function isValid($XSDString)
 {
     $ok = false;
     try {
         $this->xml->schemaValidateSource($XSDString);
         $ok = true;
     } catch (\ErrorException $e) {
         $this->errorMessage = $e->getMessage();
     }
     return $ok;
 }
开发者ID:ThomasArnaud,项目名称:ShoppingFlux,代码行数:11,代码来源:Request.php

示例2: validateCybertipSchema

 public function validateCybertipSchema(EntityEnclosingRequest $req)
 {
     $xsd = $this->getConfig()->get('xsd');
     $error = null;
     $prev = libxml_use_internal_errors(true);
     try {
         $body = (string) $req->getBody();
         $dom = new \DOMDocument();
         $dom->loadXML($body);
         $ret = $dom->schemaValidateSource($xsd);
         if (!$ret) {
             $error = self::libxmlErrorExceptionFactory();
         }
     } catch (\Exception $e) {
         $error = $e;
     }
     libxml_use_internal_errors($prev);
     if ($error instanceof \Exception) {
         throw $error;
     } else {
         if ($error) {
             throw new XsdValidateException($error);
         }
     }
 }
开发者ID:jbboehr,项目名称:cybertip,代码行数:25,代码来源:CybertipClient.php

示例3: schemaValidate

 public function schemaValidate($filename)
 {
     if (!file_exists($filename) || !filesize($filename)) {
         throw new Exception('Empty file supplied as input');
     }
     return parent::schemaValidateSource(file_get_contents($filename));
 }
开发者ID:DBezemer,项目名称:server,代码行数:7,代码来源:KDOMDocument.php

示例4: parseFile

    /**
     * Validates and parses the given file into a SimpleXMLElement
     *
     * @param  string $file
     * @return SimpleXMLElement
     */
    private function parseFile($file)
    {
        $dom = new \DOMDocument();
        $current = libxml_use_internal_errors(true);
        if (!@$dom->load($file, LIBXML_COMPACT)) {
            throw new \RuntimeException(implode("\n", $this->getXmlErrors()));
        }

        $location = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
        $parts = explode('/', $location);
        if (preg_match('#^phar://#i', $location)) {
            $tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
            if ($tmpfile) {
                file_put_contents($tmpfile, file_get_contents($location));
                $tmpfiles[] = $tmpfile;
                $parts = explode('/', str_replace('\\', '/', $tmpfile));
            }
        }
        $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
        $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));

        $source = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
        $source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source);

        if (!@$dom->schemaValidateSource($source)) {
            throw new \RuntimeException(implode("\n", $this->getXmlErrors()));
        }
        $dom->validateOnParse = true;
        $dom->normalizeDocument();
        libxml_use_internal_errors($current);

        return simplexml_import_dom($dom);
    }
开发者ID:noloman,项目名称:mtproject,代码行数:39,代码来源:XliffFileLoader.php

示例5: stringMatches

 /**
  * {@inheritdoc}
  */
 protected function stringMatches($other)
 {
     $internalErrors = libxml_use_internal_errors(true);
     $disableEntities = libxml_disable_entity_loader(true);
     libxml_clear_errors();
     $dom = new \DOMDocument();
     $dom->preserveWhiteSpace = false;
     $dom->validateOnParse = true;
     if (!@$dom->loadXML($other, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
         libxml_disable_entity_loader($disableEntities);
         $this->setXMLConstraintErrors();
         libxml_clear_errors();
         libxml_use_internal_errors($internalErrors);
         return false;
     }
     $dom->normalizeDocument();
     libxml_disable_entity_loader($disableEntities);
     libxml_clear_errors();
     if (false === ($result = @$dom->schemaValidateSource($this->XSD))) {
         $this->setXMLConstraintErrors();
     }
     libxml_clear_errors();
     libxml_use_internal_errors($internalErrors);
     return $result;
 }
开发者ID:GeckoPackages,项目名称:GeckoPHPUnit,代码行数:28,代码来源:XMLMatchesXSDConstraint.php

示例6: testExportSites

 public function testExportSites()
 {
     $foo = Site::newForType(Site::TYPE_UNKNOWN);
     $foo->setGlobalId('Foo');
     $acme = Site::newForType(Site::TYPE_UNKNOWN);
     $acme->setGlobalId('acme.com');
     $acme->setGroup('Test');
     $acme->addLocalId(Site::ID_INTERWIKI, 'acme');
     $acme->setPath(Site::PATH_LINK, 'http://acme.com/');
     $tmp = tmpfile();
     $exporter = new SiteExporter($tmp);
     $exporter->exportSites(array($foo, $acme));
     fseek($tmp, 0);
     $xml = fread($tmp, 16 * 1024);
     $this->assertContains('<sites ', $xml);
     $this->assertContains('<site>', $xml);
     $this->assertContains('<globalid>Foo</globalid>', $xml);
     $this->assertContains('</site>', $xml);
     $this->assertContains('<globalid>acme.com</globalid>', $xml);
     $this->assertContains('<group>Test</group>', $xml);
     $this->assertContains('<localid type="interwiki">acme</localid>', $xml);
     $this->assertContains('<path type="link">http://acme.com/</path>', $xml);
     $this->assertContains('</sites>', $xml);
     // NOTE: HHVM (at least on wmf Jenkins) doesn't like file URLs.
     $xsdFile = __DIR__ . '/../../../../docs/sitelist-1.0.xsd';
     $xsdData = file_get_contents($xsdFile);
     $document = new DOMDocument();
     $document->loadXML($xml, LIBXML_NONET);
     $document->schemaValidateSource($xsdData);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:30,代码来源:SiteExporterTest.php

示例7: checkValidityToXmlSchema

 /**
  * Checks whether XML is valid to XMLSchema.
  * @param DOMDocument $xmlDom source XML
  * @param string $schemaString source XMLSchema
  */
 protected function checkValidityToXmlSchema(DOMDocument $xmlDom, $schemaString)
 {
     $this->useLibxmlErrors();
     // var_dump($schemaString);
     try {
         $xmlDom->schemaValidateSource($schemaString);
     } catch (Exception $ex) {
         if ($this->reachGoalOnNoLibxmlErrors(self::goalValidToSchema, null)) {
             $this->addError("An error occurred while validating the document. This should not have happened. " . $ex->getMessage());
         }
         return;
     }
     $this->reachGoalOnNoLibxmlErrors(self::goalValidToSchema, null);
 }
开发者ID:pombredanne,项目名称:xmlcheck-public,代码行数:19,代码来源:TestXmlSchema.php

示例8: validate

 /**
  * Validate an XML string against the schema
  *
  * @param $string
  *
  * @throws \Exception
  *
  * @return boolean
  */
 public function validate($string)
 {
     $dom = new \DOMDocument();
     $originalErrorLevel = libxml_use_internal_errors(true);
     $dom->loadXML($string);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     if ($errors) {
         throw new InvalidXmlException($errors);
     }
     // ---
     $dom->schemaValidateSource($this->xml);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     if ($errors) {
         throw new InvalidSchemaException($errors);
     }
     libxml_use_internal_errors($originalErrorLevel);
     return true;
 }
开发者ID:TheKnarf,项目名称:php-raml-parser,代码行数:29,代码来源:XmlSchemaDefinition.php

示例9: validateXmlByXsd

 /**
  * На вход подается содержимое XML и XSD-схемы.
  * Далее входной XML валидируется по заданной XSD-схеме
  *
  * @param $xml
  * @param $xsd
  * @return array
  */
 public function validateXmlByXsd($xml, $xsd)
 {
     $isValid = false;
     $err = [];
     libxml_use_internal_errors(true);
     $validator = new \DOMDocument('1.0', 'UTF-8');
     $validator->loadXML($xml);
     if (!$validator->schemaValidateSource($xsd)) {
         $errors = libxml_get_errors();
         $i = 1;
         foreach ($errors as $error) {
             $err[] = $error->message;
             $i++;
         }
         libxml_clear_errors();
     } else {
         $isValid = true;
     }
     libxml_use_internal_errors(false);
     return ['validation' => $isValid, 'errors' => $err];
 }
开发者ID:izyumskiy,项目名称:restsoap,代码行数:29,代码来源:Transformer.php

示例10: validate

 /**
  * Validates xml against a given schema
  *
  * @param string $xml
  * @return void
  * @throws EngineBlock_Exception in case validating itself fails or if xml does not validate
  */
 public function validate($xml)
 {
     if (!ini_get('allow_url_fopen')) {
         throw new EngineBlock_Exception('Failed validating XML, url_fopen is not allowed');
     }
     // Load schema
     $schemaXml = @file_get_contents($this->_schemaLocation);
     if ($schemaXml === false) {
         throw new EngineBlock_Exception('Failed validating XML, schema url could not be opened: "' . $this->_schemaLocation . '"');
     }
     $schemaXml = $this->_absolutizeSchemaLocations($schemaXml, $this->_schemaLocation);
     $dom = new DOMDocument();
     $dom->loadXML($xml);
     if (!@$dom->schemaValidateSource($schemaXml)) {
         $errorInfo = error_get_last();
         $errorMessage = $errorInfo['message'];
         // @todo improve parsing message by creating custom exceptions for which know that structure of messages
         $parsedErrorMessage = preg_replace('/\\{[^}]*\\}/', '', $errorMessage);
         echo '<pre>' . htmlentities(EngineBlock_Corto_XmlToArray::formatXml($xml)) . '</pre>';
         throw new EngineBlock_Exception("Metadata XML doesn't validate against schema at '{$schemaXml}', gives error:: '{$parsedErrorMessage}'");
     }
 }
开发者ID:WebSpider,项目名称:OpenConext-engineblock,代码行数:29,代码来源:Validator.php

示例11: parseFile

 /**
  * Validates and parses the given file into a SimpleXMLElement
  *
  * @param string $file
  *
  * @return \SimpleXMLElement
  */
 private function parseFile($file)
 {
     $internalErrors = libxml_use_internal_errors(true);
     $disableEntities = libxml_disable_entity_loader(true);
     libxml_clear_errors();
     $dom = new \DOMDocument();
     $dom->validateOnParse = true;
     if (!@$dom->loadXML(file_get_contents($file), LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
         libxml_disable_entity_loader($disableEntities);
         throw new \RuntimeException(implode("\n", $this->getXmlErrors($internalErrors)));
     }
     libxml_disable_entity_loader($disableEntities);
     foreach ($dom->childNodes as $child) {
         if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
             libxml_use_internal_errors($internalErrors);
             throw new \RuntimeException('Document types are not allowed.');
         }
     }
     $location = str_replace('\\', '/', __DIR__) . '/schema/dic/xliff-core/xml.xsd';
     $parts = explode('/', $location);
     if (0 === stripos($location, 'phar://')) {
         $tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
         if ($tmpfile) {
             copy($location, $tmpfile);
             $parts = explode('/', str_replace('\\', '/', $tmpfile));
         }
     }
     $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts) . '/' : '';
     $location = 'file:///' . $drive . implode('/', array_map('rawurlencode', $parts));
     $source = file_get_contents(__DIR__ . '/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
     $source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source);
     if (!@$dom->schemaValidateSource($source)) {
         throw new \RuntimeException(implode("\n", $this->getXmlErrors($internalErrors)));
     }
     $dom->normalizeDocument();
     libxml_use_internal_errors($internalErrors);
     return simplexml_import_dom($dom);
 }
开发者ID:rrehbeindoi,项目名称:symfony,代码行数:45,代码来源:XliffFileLoader.php

示例12: ext_module_manifest_parse

function ext_module_manifest_parse($xml)
{
    $dom = new DOMDocument();
    $dom->loadXML($xml);
    if ($dom->schemaValidateSource(ext_module_manifest_validate())) {
        $root = $dom->getElementsByTagName('manifest')->item(0);
        $vcode = explode(',', $root->getAttribute('versionCode'));
        $manifest['versions'] = array();
        if (is_array($vcode)) {
            foreach ($vcode as $v) {
                $v = trim($v);
                if (!empty($v)) {
                    $manifest['versions'][] = $v;
                }
            }
            $manifest['versions'][] = '0.52';
            $manifest['versions'][] = '0.6';
            $manifest['versions'] = array_unique($manifest['versions']);
        }
        $manifest['install'] = $root->getElementsByTagName('install')->item(0)->textContent;
        $manifest['uninstall'] = $root->getElementsByTagName('uninstall')->item(0)->textContent;
        $manifest['upgrade'] = $root->getElementsByTagName('upgrade')->item(0)->textContent;
        $application = $root->getElementsByTagName('application')->item(0);
        $manifest['application'] = array('name' => trim($application->getElementsByTagName('name')->item(0)->textContent), 'identifie' => trim($application->getElementsByTagName('identifie')->item(0)->textContent), 'version' => trim($application->getElementsByTagName('version')->item(0)->textContent), 'type' => trim($application->getElementsByTagName('type')->item(0)->textContent), 'ability' => trim($application->getElementsByTagName('ability')->item(0)->textContent), 'description' => trim($application->getElementsByTagName('description')->item(0)->textContent), 'author' => trim($application->getElementsByTagName('author')->item(0)->textContent), 'url' => trim($application->getElementsByTagName('url')->item(0)->textContent), 'setting' => trim($application->getAttribute('setting')) == 'true');
        $platform = $root->getElementsByTagName('platform')->item(0);
        if (!empty($platform)) {
            $manifest['platform'] = array('subscribes' => array(), 'handles' => array(), 'isrulefields' => false);
            $subscribes = $platform->getElementsByTagName('subscribes')->item(0);
            if (!empty($subscribes)) {
                $messages = $subscribes->getElementsByTagName('message');
                for ($i = 0; $i < $messages->length; $i++) {
                    $t = $messages->item($i)->getAttribute('type');
                    if (!empty($t)) {
                        $manifest['platform']['subscribes'][] = $t;
                    }
                }
            }
            $handles = $platform->getElementsByTagName('handles')->item(0);
            if (!empty($handles)) {
                $messages = $handles->getElementsByTagName('message');
                for ($i = 0; $i < $messages->length; $i++) {
                    $t = $messages->item($i)->getAttribute('type');
                    if (!empty($t)) {
                        $manifest['platform']['handles'][] = $t;
                    }
                }
            }
            $rule = $platform->getElementsByTagName('rule')->item(0);
            if (!empty($rule) && $rule->getAttribute('embed') == 'true') {
                $manifest['platform']['isrulefields'] = true;
            }
        }
        $bindings = $root->getElementsByTagName('bindings')->item(0);
        if (!empty($bindings)) {
            global $points;
            if (!empty($points)) {
                $ps = array_keys($points);
                $manifest['bindings'] = array();
                foreach ($ps as $p) {
                    $define = $bindings->getElementsByTagName($p)->item(0);
                    $manifest['bindings'][$p] = _ext_module_manifest_entries($define);
                }
            }
        }
    } else {
        $err = error_get_last();
        if ($err['type'] == 2) {
            return $err['message'];
        }
    }
    return $manifest;
}
开发者ID:hahamy,项目名称:we7,代码行数:72,代码来源:extension.mod.php

示例13: validaXML

function validaXML($cadena_xml = "", $validaSAT = true)
{
    $r = array('success' => true, 'numCtaPago' => "", 'error' => '', 'xml' => '');
    if (trim($cadena_xml) == "") {
        $r['success'] = false;
        $r['error'] = 'XML vacio';
    }
    $xml = new DOMDocument();
    //    $ctx = stream_context_create([
    //        'ssl' => [
    //            'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
    //        ],
    //    ]);
    $archivo_esquema = 'res/xml/cfdv32.xsd';
    $esquema = file_get_contents($archivo_esquema, false);
    // Validamos solamente la estructura del XML para ver si cumple con la estructura del SAT
    if ($cadena_xml !== false) {
        $datos = array("rfc_emisor" => "", "rfc_receptor" => "", "total" => "", "uuid" => "");
        $xml->loadXML($cadena_xml);
        // establecer el gestor de errores definido por el usuario
        $gestor_errores_antiguo = set_error_handler("miGestorDeErrores");
        $error = $xml->schemaValidateSource($esquema);
        //$error = true;
        // Reestablecemos el gestor de errores definido por el sistema
        restore_error_handler();
        if ($error == false || is_string($error) || is_array($error) && $error['success'] == false) {
            $r['success'] = false;
            $msg = is_array($error) || is_string($error) ? "" . $error['errstr'] : "El archivo XML no cumple con la estructura del CFDI del SAT.";
            $r['error'] = "XML con formato incorrecto.<br><br>" . $msg;
        } else {
            $array = XML2Array::createArray($cadena_xml);
            $r['xml'] = $array;
            $error = array();
            if (isset($array) && $array != false && count($array) > 0) {
                if (!valid_rfc($array['cfdi:Comprobante']['cfdi:Emisor']['@attributes']['rfc'])) {
                    $error[] = "RFC del emisor invalido";
                    $r['success'] = false;
                } else {
                    $r['rfc_emisor'] = $datos['rfc_emisor'] = $array['cfdi:Comprobante']['cfdi:Emisor']['@attributes']['rfc'];
                }
                if (!valid_rfc($array['cfdi:Comprobante']['cfdi:Receptor']['@attributes']['rfc'])) {
                    $error[] = "RFC del receptor inválido";
                    $r['success'] = false;
                } else {
                    $r['rfc_receptor'] = $datos['rfc_receptor'] = $array['cfdi:Comprobante']['cfdi:Receptor']['@attributes']['rfc'];
                }
                if (isset($array['cfdi:Comprobante']['@attributes']['NumCtaPago']) && $array['cfdi:Comprobante']['@attributes']['NumCtaPago']) {
                    $r['numCtaPago'] = $array['cfdi:Comprobante']['@attributes']['NumCtaPago'];
                }
                if (isset($array['cfdi:Comprobante']['@attributes']['total']) && $array['cfdi:Comprobante']['@attributes']['total']) {
                    $datos['total'] = $array['cfdi:Comprobante']['@attributes']['total'];
                } else {
                    //$datos['total'] = 0;
                    $error[] = "La factura no tiene importe de TOTAL";
                    $r['success'] = false;
                }
                $datos['uuid'] = $array['cfdi:Comprobante']['cfdi:Complemento']['tfd:TimbreFiscalDigital']['@attributes']['UUID'];
                if (isset($array['cfdi:Comprobante']['cfdi:Complemento']['tfd:TimbreFiscalDigital']['@attributes']['UUID']) && $array['cfdi:Comprobante']['cfdi:Complemento']['tfd:TimbreFiscalDigital']['@attributes']['UUID']) {
                    $datos['uuid'] = $array['cfdi:Comprobante']['cfdi:Complemento']['tfd:TimbreFiscalDigital']['@attributes']['UUID'];
                } else {
                    $error[] = "La factura no tiene UUID";
                    $r['success'] = false;
                }
                if ($r['success'] && $validaSAT === true) {
                    //$t = json_encode(array('success' => true, 'mensaje' => 'Validando con el SAT'));
                    $sat = validarXMLenSAT($datos);
                    if (substr($sat['CodigoEstatus'], 0, 1) == "N") {
                        $error[] = "El SAT reporta: " . $sat['CodigoEstatus'] . "<br>Estado: " . $sat['Estado'];
                        $r['success'] = false;
                    }
                }
                $r['error'] = "";
                if (count($error) > 0) {
                    $r['error'] = implode("<br><br><br>", $error);
                }
            }
        }
    }
    return $r;
}
开发者ID:rodrigo2000,项目名称:googleTransitUI,代码行数:80,代码来源:validarxml_helper.php

示例14: profiling_import_runs

/**
 * Import a .mpr (moodle profile runs) file into moodle.
 *
 * See {@link profiling_export_runs()} for more details about the
 * implementation of .mpr files.
 *
 * @param string $file filesystem fullpath to target .mpr file.
 * @param string $commentprefix prefix to add to the comments of all the imported runs.
 * @return boolean the mpr file has been successfully imported (true) or no (false).
 */
function profiling_import_runs($file, $commentprefix = '')
{
    global $DB;
    // Any problem with the file or its directory, abort.
    if (!file_exists($file) or !is_readable($file) or !is_writable(dirname($file))) {
        return false;
    }
    // Unzip the file into temp directory.
    $tmpdir = dirname($file) . '/' . time() . '_' . random_string(4);
    $fp = get_file_packer('application/vnd.moodle.profiling');
    $status = $fp->extract_to_pathname($file, $tmpdir);
    // Look for master file and verify its format.
    if ($status) {
        $mfile = $tmpdir . '/moodle_profiling_runs.xml';
        if (!file_exists($mfile) or !is_readable($mfile)) {
            $status = false;
        } else {
            $mdom = new DOMDocument();
            if (!$mdom->load($mfile)) {
                $status = false;
            } else {
                $status = @$mdom->schemaValidateSource(profiling_get_import_main_schema());
            }
        }
    }
    // Verify all detail files exist and verify their format.
    if ($status) {
        $runs = $mdom->getElementsByTagName('run');
        foreach ($runs as $run) {
            $rfile = $tmpdir . '/' . clean_param($run->getAttribute('ref'), PARAM_FILE);
            if (!file_exists($rfile) or !is_readable($rfile)) {
                $status = false;
            } else {
                $rdom = new DOMDocument();
                if (!$rdom->load($rfile)) {
                    $status = false;
                } else {
                    $status = @$rdom->schemaValidateSource(profiling_get_import_run_schema());
                }
            }
        }
    }
    // Everything looks ok, let's import all the runs.
    if ($status) {
        reset($runs);
        foreach ($runs as $run) {
            $rfile = $tmpdir . '/' . $run->getAttribute('ref');
            $rdom = new DOMDocument();
            $rdom->load($rfile);
            $runarr = array();
            $runarr['runid'] = clean_param($rdom->getElementsByTagName('runid')->item(0)->nodeValue, PARAM_ALPHANUMEXT);
            $runarr['url'] = clean_param($rdom->getElementsByTagName('url')->item(0)->nodeValue, PARAM_CLEAN);
            $runarr['runreference'] = clean_param($rdom->getElementsByTagName('runreference')->item(0)->nodeValue, PARAM_INT);
            $runarr['runcomment'] = $commentprefix . clean_param($rdom->getElementsByTagName('runcomment')->item(0)->nodeValue, PARAM_CLEAN);
            $runarr['timecreated'] = time();
            // Now.
            $runarr['totalexecutiontime'] = clean_param($rdom->getElementsByTagName('totalexecutiontime')->item(0)->nodeValue, PARAM_INT);
            $runarr['totalcputime'] = clean_param($rdom->getElementsByTagName('totalcputime')->item(0)->nodeValue, PARAM_INT);
            $runarr['totalcalls'] = clean_param($rdom->getElementsByTagName('totalcalls')->item(0)->nodeValue, PARAM_INT);
            $runarr['totalmemory'] = clean_param($rdom->getElementsByTagName('totalmemory')->item(0)->nodeValue, PARAM_INT);
            $runarr['data'] = clean_param($rdom->getElementsByTagName('data')->item(0)->nodeValue, PARAM_CLEAN);
            // If the runid does not exist, insert it.
            if (!$DB->record_exists('profiling', array('runid' => $runarr['runid']))) {
                $DB->insert_record('profiling', $runarr);
            } else {
                return false;
            }
        }
    }
    // Clean the temp directory used for import.
    remove_dir($tmpdir);
    return $status;
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:83,代码来源:xhprof_moodle.php

示例15: DOMDocument

<?php

$doc = new DOMDocument();
$doc->load(dirname(__FILE__) . "/book-attr.xml");
$xsd = file_get_contents(dirname(__FILE__) . "/book.xsd");
$doc->schemaValidateSource($xsd);
foreach ($doc->getElementsByTagName('book') as $book) {
    var_dump($book->getAttribute('is-hardback'));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:DOMDocument_schemaValidateSource_missingAttrs.php


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