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


PHP libxml_use_internal_errors函数代码示例

本文整理汇总了PHP中libxml_use_internal_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP libxml_use_internal_errors函数的具体用法?PHP libxml_use_internal_errors怎么用?PHP libxml_use_internal_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: request

 /**
  * @param string $url
  * @param string $method
  * @param string $body
  *
  * @return FhirResponse
  */
 public function request($url, $method = 'GET', $body = null)
 {
     $server_name = null;
     foreach ($this->servers as $name => $server) {
         if (substr($url, 0, strlen($server['base_url']))) {
             $server_name = $name;
             break;
         }
     }
     $this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
     $this->http_client->setUri($url);
     $this->http_client->setMethod($method);
     if ($body) {
         $this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
     }
     $response = $this->http_client->request();
     $this->http_client->resetParameters();
     if ($body = $response->getBody()) {
         $use_errors = libxml_use_internal_errors(true);
         $value = Yii::app()->fhirMarshal->parseXml($body);
         $errors = libxml_get_errors();
         libxml_use_internal_errors($use_errors);
         if ($errors) {
             throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
         }
     } else {
         $value = null;
     }
     return new FhirResponse($response->getStatus(), $value);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:37,代码来源:FhirClient.php

示例2: setLaundryState

 public function setLaundryState(&$laundryPlace)
 {
     $user = 'youruser';
     $pass = 'yourpassword';
     try {
         $client = new Client($laundryPlace['url']);
         $request = $client->get('/LaundryState', [], ['auth' => [$user, $pass, 'Digest'], 'timeout' => 1.5, 'connect_timeout' => 1.5]);
         $response = $request->send();
         $body = $response->getBody();
         libxml_use_internal_errors(true);
         $crawler = new Crawler();
         $crawler->addContent($body);
         foreach ($crawler->filter('img') as $img) {
             $resource = $img->getAttribute('src');
             $img->setAttribute('src', 'http://129.241.126.11/' . trim($resource, '/'));
         }
         $crawler->addHtmlContent('<h1>foobar</h1>');
         //'<link href="http://129.241.126.11/pic/public_n.css" type="text/css">');
         $laundryPlace['html'] = $crawler->html();
         libxml_use_internal_errors(false);
         preg_match_all('/bgColor=Green/', $body, $greenMatches);
         preg_match_all('/bgColor=Red/', $body, $redMatches);
         $laundryPlace['busy'] = count($redMatches[0]);
         $laundryPlace['available'] = count($greenMatches[0]);
     } catch (\Exception $e) {
         $laundryPlace['available'] = self::NETWORK_ERROR;
         $laundryPlace['busy'] = self::NETWORK_ERROR;
         $laundryPlace['html'] = self::NETWORK_ERROR;
     }
 }
开发者ID:kcisek,项目名称:sit-washing,代码行数:30,代码来源:MieleService.php

示例3: load

 /**
  * Returns array of simple xml objects, where key is a handle name
  *
  * @return SimpleXmlElement[]
  * @throws RuntimeException in case of load error (malformed xml, etc)
  */
 public function load()
 {
     $this->validate();
     $original = libxml_use_internal_errors(true);
     $simpleXmlElement = simplexml_load_file($this->filePath);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     libxml_use_internal_errors($original);
     if ($simpleXmlElement === false) {
         $messages = array();
         foreach ($errors as $error) {
             $messages[] = sprintf('%s, line %s, column %s', trim($error->message), $error->line, $error->column);
         }
         throw new RuntimeException(sprintf('File "%s" has a malformed xml structure: %s', $this->filePath, PHP_EOL . implode(PHP_EOL, $messages)));
     }
     $stringXml = array();
     // First convert all elements to string,
     // as in xml file can be multiple string with the same handle names
     foreach ($simpleXmlElement->children() as $key => $element) {
         if (!isset($stringXml[$key])) {
             $stringXml[$key] = '';
         }
         foreach ($element->children() as $child) {
             $stringXml[$key] .= $child->asXml();
         }
     }
     $result = array();
     foreach ($stringXml as $key => $xml) {
         $result[$key] = simplexml_load_string(sprintf('<%1$s>%2$s</%1$s>', $key, $xml));
     }
     return $result;
 }
开发者ID:albertobraschi,项目名称:EcomDev_LayoutCompiler,代码行数:38,代码来源:File.php

示例4: validateXml

 /**
  * Validate XML to be valid for import
  * @param string $xml
  * @param WP_Error[optional] $errors
  * @return bool Validation status
  */
 public static function validateXml(&$xml, $errors = NULL)
 {
     if (FALSE === $xml or '' == $xml) {
         $errors and $errors->add('form-validation', __('WP All Import can\'t read your file.<br/><br/>Probably, you are trying to import an invalid XML feed. Try opening the XML feed in a web browser (Google Chrome is recommended for opening XML files) to see if there is an error message.<br/>Alternatively, run the feed through a validator: http://validator.w3.org/<br/>99% of the time, the reason for this error is because your XML feed isn\'t valid.<br/>If you are 100% sure you are importing a valid XML feed, please contact WP All Import support.', 'wp_all_import_plugin'));
     } else {
         PMXI_Import_Record::preprocessXml($xml);
         if (function_exists('simplexml_load_string')) {
             libxml_use_internal_errors(true);
             libxml_clear_errors();
             $_x = @simplexml_load_string($xml);
             $xml_errors = libxml_get_errors();
             libxml_clear_errors();
             if ($xml_errors) {
                 $error_msg = '<strong>' . __('Invalid XML', 'wp_all_import_plugin') . '</strong><ul>';
                 foreach ($xml_errors as $error) {
                     $error_msg .= '<li>';
                     $error_msg .= __('Line', 'wp_all_import_plugin') . ' ' . $error->line . ', ';
                     $error_msg .= __('Column', 'wp_all_import_plugin') . ' ' . $error->column . ', ';
                     $error_msg .= __('Code', 'wp_all_import_plugin') . ' ' . $error->code . ': ';
                     $error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
                     $error_msg .= '</li>';
                 }
                 $error_msg .= '</ul>';
                 $errors and $errors->add('form-validation', $error_msg);
             } else {
                 return true;
             }
         } else {
             $errors and $errors->add('form-validation', __('Required PHP components are missing.', 'wp_all_import_plugin'));
             $errors and $errors->add('form-validation', __('WP All Import requires the SimpleXML PHP module to be installed. This is a standard feature of PHP, and is necessary for WP All Import to read the files you are trying to import.<br/>Please contact your web hosting provider and ask them to install and activate the SimpleXML PHP module.', 'wp_all_import_plugin'));
         }
     }
     return false;
 }
开发者ID:k-hasan-19,项目名称:wp-all-import,代码行数:40,代码来源:record.php

示例5: validate

		public function validate($xml,$schema) {
			// Enable user error handling
			libxml_use_internal_errors(true);

			try {
				if(empty($xml)) {
					throw new Exception("You provided an empty XML string");
				}
				
				$doc = DOMDocument::loadXML($xml);
				if(!($doc instanceof DOMDocument)){
					$this->_errors = libxml_get_errors();
				}
	
				if(!@$doc->schemaValidate($schema)){
			        $this->_errors = libxml_get_errors();
				}
			} catch (Exception $e) {
				$this->_errors = array(0 => array('message'=>$e->getMessage()));
			}

			// Disable user error handling & Error Cleanup
			libxml_use_internal_errors(false);
			libxml_clear_errors();

			// If there are no errors, assume that it is all OK!
			return empty($this->_errors);
    	}
开发者ID:remie,项目名称:schemadevkit,代码行数:28,代码来源:SchemaValidator.php

示例6: layerslider_init

function layerslider_init($atts)
{
    // ID check
    if (empty($atts['id'])) {
        return '[LayerSliderWP] ' . __('Invalid shortcode', 'LayerSlider') . '';
    }
    // Get slider
    $slider = LS_Sliders::find($atts['id']);
    // Get slider if any
    if (!$slider || $slider['flag_deleted'] == '1') {
        return '[LayerSliderWP] ' . __('Slider not found', 'LayerSlider') . '';
    }
    // Slider and markup data
    $slides = $slider['data'];
    $id = $slider['id'];
    $data = '';
    // Include slider file
    if (is_array($slides)) {
        // Get phpQuery
        if (!class_exists('phpQuery')) {
            libxml_use_internal_errors(true);
            include LS_ROOT_PATH . '/helpers/phpQuery.php';
        }
        include LS_ROOT_PATH . '/config/defaults.php';
        include LS_ROOT_PATH . '/includes/slider_markup_init.php';
        include LS_ROOT_PATH . '/includes/slider_markup_html.php';
        $data = implode('', $data);
    }
    // Return data
    if (get_option('ls_concatenate_output', true)) {
        $data = trim(preg_replace('/\\s+/u', ' ', $data));
    }
    return $data;
}
开发者ID:ftopolovec,项目名称:proart,代码行数:34,代码来源:shortcodes.php

示例7: runTest

 public function runTest()
 {
     libxml_use_internal_errors(true);
     $xml = XMLReader::open(join(DIRECTORY_SEPARATOR, array($this->directory, $this->fileName)));
     $xml->setSchema(join(DIRECTORY_SEPARATOR, array($this->directory, $this->xsdFilename)));
     $this->logger->trace(__METHOD__);
     $this->logger->info('  XML file to test validity is ' . $this->fileName . 'using XSD file ' . $this->xsdFilename);
     // You have to parse the XML-file if you want it to be validated
     $currentReadCount = 1;
     $validationFailed = false;
     while ($xml->read() && $validationFailed == false) {
         // I want to break as soon as file is shown not to be valid
         // We could allow it to collect a few messages, but I think it's best
         // to do a manual check once we have discovered the file is not
         // correct. Speed is really what we want here!
         if ($currentReadCount++ % Constants::XML_PROCESSESING_CHECK_ERROR_COUNT == 0) {
             if (count(libxml_get_errors()) > 0) {
                 $validationFailed = true;
             }
         }
     }
     if (count(libxml_get_errors()) == 0) {
         $this->testProperty->addTestResult(true);
         $this->logger->info(' RESULT Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] succeeded');
         $this->testProperty->addTestResultDescription('Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] succeeded');
         $this->testProperty->addTestResultReportDescription('Filen ' . $this->fileName . ' validerer mot filen' . $this->xsdFilename);
     } else {
         $this->testProperty->addTestResult(false);
         $this->logger->error(' RESULT Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] failed');
         $this->testProperty->addTestResultDescription('Validation of [' . $this->fileName . '] against [' . $this->xsdFilename . '] failed');
         $this->testProperty->addTestResultReportDescription('Filen ' . $this->fileName . ' validerer ikke mot filen' . $this->xsdFilename);
     }
     libxml_clear_errors();
 }
开发者ID:HaakonME,项目名称:noark5-validator,代码行数:34,代码来源:XMLTestValidation.php

示例8: validateXML

 /**
  * This function attempts to validate an XML string against the specified schema.
  *
  * It will parse the string into a DOM document and validate this document against the schema.
  *
  * @param string  $xml    The XML string or document which should be validated.
  * @param string  $schema The schema filename which should be used.
  * @param boolean $debug  To disable/enable the debug mode
  *
  * @return string | DOMDocument $dom  string that explains the problem or the DOMDocument
  */
 public static function validateXML($xml, $schema, $debug = false)
 {
     assert('is_string($xml) || $xml instanceof DOMDocument');
     assert('is_string($schema)');
     libxml_clear_errors();
     libxml_use_internal_errors(true);
     if ($xml instanceof DOMDocument) {
         $dom = $xml;
     } else {
         $dom = new DOMDocument();
         $dom = self::loadXML($dom, $xml);
         if (!$dom) {
             return 'unloaded_xml';
         }
     }
     $schemaFile = dirname(__FILE__) . '/schemas/' . $schema;
     $oldEntityLoader = libxml_disable_entity_loader(false);
     $res = $dom->schemaValidate($schemaFile);
     libxml_disable_entity_loader($oldEntityLoader);
     if (!$res) {
         $xmlErrors = libxml_get_errors();
         syslog(LOG_INFO, 'Error validating the metadata: ' . var_export($xmlErrors, true));
         if ($debug) {
             foreach ($xmlErrors as $error) {
                 echo $error->message . "\n";
             }
         }
         return 'invalid_xml';
     }
     return $dom;
 }
开发者ID:faxe-kommune,项目名称:OS2loop,代码行数:42,代码来源:Utils.php

示例9: __construct

 public function __construct()
 {
     $this->rssStream = null;
     $this->rss = null;
     //disable XML error
     libxml_use_internal_errors(true);
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:7,代码来源:rssnotifierservice.class.php

示例10: parse

 /**
  * private function that generalizes parsing
  * @param $string
  * @param null $names
  * @return array
  */
 private static function parse($string, $names = NULL)
 {
     $dom = new DOMDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($string);
     $metas = $dom->getElementsByTagName('meta');
     $metaArray = array();
     if ($names == NULL) {
         foreach ($metas as $meta) {
             $nameKey = $meta->getAttribute('name');
             $contentValue = $meta->getAttribute('content');
             $metaArray["{$nameKey}"] = $contentValue;
         }
     } else {
         foreach ($names as $name) {
             foreach ($metas as $meta) {
                 if ($name === $meta->getAttribute('name')) {
                     $nameKey = $meta->getAttribute('name');
                     $contentValue = $meta->getAttribute('content');
                     $metaArray["{$nameKey}"] = $contentValue;
                 }
             }
         }
     }
     return $metaArray;
 }
开发者ID:isko-algorithm,项目名称:php-es-indexer,代码行数:32,代码来源:MetaParser.php

示例11: parse

 /**
  * Parse the given file for apprentices and mentors.
  *
  * @param string $file Path to the File to parse.
  *
  * @return array
  */
 public function parse($file)
 {
     $return = array('mentors' => array(), 'apprentices' => array());
     $content = file_Get_contents($file);
     $content = str_Replace('<local-time', '<span tag="local-time"', $content);
     $content = str_Replace('</local-time', '</span', $content);
     $content = str_Replace('<time', '<span tag="time"', $content);
     $content = str_Replace('</time', '</span', $content);
     $this->dom = new \DomDocument('1.0', 'UTF-8');
     $this->dom->strictErrorChecking = false;
     libxml_use_internal_errors(true);
     $this->dom->loadHTML('<?xml encoding="UTF-8" ?>' . $content);
     libxml_use_internal_errors(false);
     $xpathMentors = new \DOMXPath($this->dom);
     $mentors = $xpathMentors->query('//a[@id="user-content-mentors-currently-accepting-an-apprentice"]/../following-sibling::ul[1]/li');
     foreach ($mentors as $mentor) {
         $user = $this->parseUser($mentor);
         if (!$user) {
             continue;
         }
         $user['type'] = 'mentor';
         $return['mentors'][] = $user;
     }
     $xpathApprentices = new \DOMXPath($this->dom);
     $apprentices = $xpathApprentices->query('//a[@id="user-content-apprentices-currently-accepting-mentors"]/../following-sibling::ul[1]/li');
     foreach ($apprentices as $apprentice) {
         $user = $this->parseUser($apprentice);
         if (!$user) {
             continue;
         }
         $user['type'] = 'apprentice';
         $return['apprentices'][] = $user;
     }
     return $return;
 }
开发者ID:tsilvers,项目名称:php.ug,代码行数:42,代码来源:Mentoring.php

示例12: parseHtml

 function parseHtml()
 {
     //$this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     /*
     $p = xml_parser_create();
     xml_parse_into_struct($p, $this->_html, $vals, $index);
     xml_parser_free($p);
     echo "Index array\n";
     pr($index);
     echo "\nVals array\n";
     pr($vals);
     die;
     */
     /*
     $this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     $__data = new SimpleXMLElement($this->_html);
     pr($__data); die;
     */
     $dom = new DOMDocument();
     //echo htmlentities($this->_html); die;
     libxml_use_internal_errors(true);
     //$this->_html = str_replace("<!DOCTYPE html>", "", $this->_html);
     //$this->_html = str_replace("</h1>", "", $this->_html);
     //echo htmlentities($this->_html); die;
     //echo htmlentities($this->_html); die;
     $dom->loadHTML($this->_html);
     foreach ($dom->getElementsByTagName('img') as $node) {
         $array[] = $dom->saveHTML($node);
     }
     //pr($array);
     //die;
 }
开发者ID:str33thack3r,项目名称:wp01,代码行数:32,代码来源:find-html-issues.php

示例13: getXMLData

 public function getXMLData()
 {
     $prevVal = libxml_use_internal_errors(true);
     $data = new \SimpleXMLElement($this->request->getRawData());
     libxml_use_internal_errors($prevVal);
     return $data;
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:7,代码来源:XMLInput.php

示例14: 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

示例15: __construct

 /**
  * Class constructor initialises the SimpleXML object and sets a few properties.
  * @param string $filepath Optional filespec for the XML file to use. Will use default otherwise.
  * @throws \Exception If the XML is invalid.
  */
 public function __construct($filepath = null)
 {
     if (empty($filepath)) {
         if (defined('nZEDb_VERSIONS')) {
             $filepath = nZEDb_VERSIONS;
         }
     }
     if (!file_exists($filepath)) {
         throw new \RuntimeException("Versions file '{$filepath}' does not exist!'");
     }
     $this->_filespec = $filepath;
     $this->out = new \ColorCLI();
     $this->git = new Git();
     $temp = libxml_use_internal_errors(true);
     $this->_xml = simplexml_load_file($filepath);
     libxml_use_internal_errors($temp);
     if ($this->_xml === false) {
         if (Utility::isCLI()) {
             $this->out->error("Your versions XML file ({nZEDb_VERSIONS}) is broken, try updating from git.");
         }
         throw new \Exception("Failed to open versions XML file '{$filepath}'");
     }
     if ($this->_xml->count() > 0) {
         $vers = $this->_xml->xpath('/nzedb/versions');
         if ($vers[0]->count() == 0) {
             $this->out->error("Your versions XML file ({nZEDb_VERSIONS}) does not contain version info, try updating from git.");
             throw new \Exception("Failed to find versions node in XML file '{$filepath}'");
         } else {
             $this->out->primary("Your versions XML file ({nZEDb_VERSIONS}) looks okay, continuing.");
             $this->_vers =& $this->_xml->versions;
         }
     } else {
         throw new \RuntimeException("No elements in file!\n");
     }
 }
开发者ID:Jay204,项目名称:nZEDb,代码行数:40,代码来源:Versions.php


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