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


PHP xml_parser_create函数代码示例

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


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

示例1: xmlParser

 function xmlParser()
 {
     $this->xml_obj = xml_parser_create();
     xml_set_object($this->xml_obj, $this);
     xml_set_character_data_handler($this->xml_obj, 'dataHandler');
     xml_set_element_handler($this->xml_obj, "startHandler", "endHandler");
 }
开发者ID:retnan,项目名称:TrunkSMS,代码行数:7,代码来源:class.xml.parser.php

示例2: __construct

 /**
  * Constructs FormFilter
  * @access public
  */
 function __construct()
 {
     $this->parser = xml_parser_create();
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, 'open', 'close');
     xml_set_character_data_handler($this->parser, 'data');
 }
开发者ID:jaywilliams,项目名称:ultralite,代码行数:11,代码来源:Form.php

示例3: parse

 public function parse($xml_or_arr)
 {
     if (is_array($xml_or_arr)) {
         $output = array();
         foreach ($xml_or_arr as $val) {
             $to = $this->parse($val);
             $output = array_merge($output, $to);
         }
         return $output;
     }
     //		echo '<h1>xml in parser:</h1><pre>'; print_r($xml); echo '</pre>';
     // if we don't start with a processing instruction,
     // we add an outer node just to ensure it's a valid xml document
     // (i.e. only a single root node)
     if (substr($xml_or_arr, 0, 2) != '<?') {
         $xml_or_arr = "<{$this->insertedNode}>" . $xml_or_arr . "</{$this->insertedNode}>";
     }
     $this->parser = xml_parser_create();
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, "tagOpen", "tagClosed");
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
     xml_set_character_data_handler($this->parser, "tagData");
     $this->xmldata = xml_parse($this->parser, $xml_or_arr);
     if (!$this->xmldata) {
         die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)));
     }
     xml_parser_free($this->parser);
     $this->parseCompleted();
     return $this->output;
 }
开发者ID:ilri,项目名称:genebank-gg_server,代码行数:31,代码来源:parsers.php

示例4: _loadTranslationData

 /**
  * Load translation data (TMX file reader)
  *
  * @param  string  $filename  TMX file to add, full path must be given for access
  * @param  string  $locale    Locale has no effect for TMX because TMX defines all languages within
  *                            the source file
  * @param  array   $option    OPTIONAL Options to use
  * @throws Zend_Translation_Exception
  */
 protected function _loadTranslationData($filename, $locale, array $options = array())
 {
     $options = array_merge($this->_options, $options);
     if ($options['clear']) {
         $this->_translate = array();
     }
     if (in_array('defined_language', $options) and !empty($options['defined_language'])) {
         $this->_defined = true;
     }
     if (!is_readable($filename)) {
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
     }
     $this->_file = xml_parser_create();
     xml_set_object($this->_file, $this);
     xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($this->_file, "_startElement", "_endElement");
     xml_set_character_data_handler($this->_file, "_contentElement");
     if (!xml_parse($this->_file, file_get_contents($filename))) {
         $ex = sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($this->_file)), xml_get_current_line_number($this->_file));
         xml_parser_free($this->_file);
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception($ex);
     }
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:34,代码来源:Tmx.php

示例5: xml

 public function xml() {
     $this->parser = xml_parser_create();    
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);    
     xml_set_object($this->parser, $this);    
     xml_set_element_handler($this->parser, 'open','close');    
     xml_set_character_data_handler($this->parser, 'data');    
 }
开发者ID:panhongsheng,项目名称:zl_cms,代码行数:7,代码来源:xml.class.php

示例6: parseFile

 function parseFile($fileLocation)
 {
     // reset it.
     $this->_docType = NULL;
     $this->_nameSpace = NULL;
     $this->_errors = NULL;
     $fp = @fopen($fileLocation, 'r');
     if ($fp) {
         $parser = xml_parser_create('ISO-8859-1');
         xml_set_object($parser, $this);
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, FALSE);
         xml_set_element_handler($parser, "_startElement", "_endElement");
         while ($data = fread($fp, 1024)) {
             if (strlen($this->_docType) > 0) {
                 break;
             }
             if (!xml_parse($parser, $data, feof($fp))) {
                 $error = xml_error_string(xml_get_error_code($parser));
                 break;
             }
         }
         xml_parser_free($parser);
         @fclose(fp);
         return TRUE;
     } else {
         $this->_errors[] = 'File ' . $fileLocation . ' could not be opened.';
         return FALSE;
     }
 }
开发者ID:horrabin,项目名称:opendb,代码行数:29,代码来源:DocTypeNameSpaceXMLParser.class.php

示例7: create

 /**
  * @return resource
  */
 protected function create()
 {
     $parser = xml_parser_create("UTF-8");
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     return $parser;
 }
开发者ID:bcncommerce,项目名称:serializer,代码行数:10,代码来源:XmlParser.php

示例8: xml

 function xml()
 {
     $this->parser = xml_parser_create();
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, "tag_open", "tag_close");
     xml_set_character_data_handler($this->parser, "cdata");
 }
开发者ID:pixlr,项目名称:zce-1,代码行数:7,代码来源:xml_set_object.php

示例9: parseXML

 public function parseXML($xml)
 {
     $xmlArray = null;
     $parser = xml_parser_create();
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
     xml_parse_into_struct($parser, $xml, $xmlArray, $indexdata);
     xml_parser_free($parser);
     $elements = array();
     $child = array();
     foreach ($xmlArray as $item) {
         $current = count($elements);
         if ($item['type'] == 'open' || $item['type'] == 'complete') {
             $elements[$current] = new \stdClass();
             $elements[$current]->tag = $item['tag'];
             $elements[$current]->attributes = array_key_exists('attributes', $item) ? $item['attributes'] : '';
             $elements[$current]->value = array_key_exists('value', $item) ? $item['value'] : '';
             if ($item['type'] == "open") {
                 $elements[$current]->children = array();
                 $child[count($child)] =& $elements;
                 $elements =& $elements[$current]->children;
             }
         } else {
             if ($item['type'] == 'close') {
                 $elements =& $child[count($child) - 1];
                 unset($child[count($child) - 1]);
             }
         }
     }
     if ($elements) {
         return $elements[0];
     } else {
         return null;
     }
 }
开发者ID:EP-NY,项目名称:FeedMe,代码行数:35,代码来源:FeedMe_FeedXMLService.php

示例10: __construct

 function __construct()
 {
     $this->xml = xml_parser_create();
     xml_set_object($this->xml, $this);
     xml_set_character_data_handler($this->xml, 'dataHandler');
     xml_set_element_handler($this->xml, 'startHandler', 'endHandler');
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:7,代码来源:class.http_svn_client.inc.php

示例11: parse

 function parse($xml)
 {
     $this->result = array();
     $this->context = $xml;
     $this->currentTag = '';
     $this->currentState = array();
     $this->xmlParser = xml_parser_create();
     xml_parser_set_option($this->xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8") . xml_set_object($this->xmlParser, $this);
     xml_set_element_handler($this->xmlParser, 'startElement', 'endElement');
     xml_set_character_data_handler($this->xmlParser, 'content');
     $this->trigger('before:import');
     try {
         if (!xml_parse($this->xmlParser, $xml)) {
             $this->xmlParserError = 'Line ' . xml_get_current_line_number($this->xmlParser) . ': ' . (xml_get_error_code($this->xmlParser) ? xml_error_string(xml_get_error_code($this->xmlParser)) : 'Unknown error');
         }
     } catch (Exception $e) {
         $this->xmlParserError = $e->getMessage();
     }
     xml_parser_free($this->xmlParser);
     if ($this->xmlParserError) {
         $this->raiseError($this->xmlParserError);
     } else {
         if ($this->getCurrentState()) {
             $this->raiseError('Wrong ending state: ' . $this->getCurrentState());
         } else {
         }
     }
     $this->trigger('after:import');
     return $this->result;
 }
开发者ID:jagermesh,项目名称:bright,代码行数:30,代码来源:BrXMLParser.php

示例12: __construct

 function __construct($charset = 'UTF-8')
 {
     $this->conf = array();
     $this->conf['error'] = '<br /><strong>Error on line %s of ' . __FILE__ . '</strong>: %s<br />';
     $this->conf['cache_path'] = dirname(__FILE__);
     $this->conf['cache_time'] = 180;
     $this->conf['debug_mode'] = true;
     $this->conf['fetch_mode'] = ONYX_FETCH_ASSOC;
     if (!function_exists('xml_parser_create')) {
         $this->raiseError(__LINE__ - 2, ONYX_ERR_NO_PARSER);
         return false;
     }
     if ($charset == 'native') {
         $charset = LANG_CHARSET;
     }
     $this->parser = @xml_parser_create($charset);
     if (!is_resource($this->parser)) {
         $this->raiseError(__LINE__ - 3, ONYX_ERR_NO_PARSER);
         return false;
     }
     xml_set_object($this->parser, $this);
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
     @xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, LANG_CHARSET);
     xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
     xml_set_character_data_handler($this->parser, 'cdata');
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:26,代码来源:RSS.php

示例13: GetStatus

 function GetStatus($ip, $port, $pw)
 {
     error_reporting(0);
     $fp = fsockopen($ip, $port, $errno, $errstr, 1);
     if (!$fp) {
         error_reporting(E_ALL);
         $this->error = "{$errstr} ({$errno})";
         return 0;
     } else {
         error_reporting(E_ALL);
         socket_set_timeout($fp, 2);
         fputs($fp, "GET /stats?sid=1?pass=" . $pw . "&mode=viewxml HTTP/1.1\r\n");
         //  original --> admin.cgi?pass
         fputs($fp, "User-Agent: Mozilla\r\n\r\n");
         while (!feof($fp)) {
             $this->SHOUTcastData .= fgets($fp, 512);
         }
         fclose($fp);
         if (stristr($this->SHOUTcastData, "HTTP/1.1 200 OK") == true) {
             $this->SHOUTcastData = trim(substr($this->SHOUTcastData, 58));
         } else {
             $this->error = "Bad login";
             return 0;
         }
         $xmlparser = xml_parser_create('UTF-8');
         //xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes);
         if (!xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes)) {
             $this->error = "Unparsable XML";
             return 0;
         }
         xml_parser_free($this->values);
         return 1;
     }
 }
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:34,代码来源:gr_radiostatus_class.php

示例14: load

 protected function load()
 {
     global $zf_opmlItems, $zf_opmlMode;
     /* default values for parsing this opml file */
     $zf_opmlItems = array();
     $xml_parser = xml_parser_create();
     xml_set_element_handler($xml_parser, "zf_opmlStartElement", "zf_opmlEndElement");
     zf_debug('Opening file ' . $this->opmlfilename, DBG_OPML);
     @($fp = fopen($this->opmlfilename, "r"));
     $data = "";
     if ($fp) {
         $data = fread($fp, filesize($this->opmlfilename));
         fclose($fp);
         $xmlResult = xml_parse($xml_parser, $data);
         $xmlError = xml_error_string(xml_get_error_code($xml_parser));
         $xmlCrtline = xml_get_current_line_number($xml_parser);
         xml_parser_free($xml_parser);
         unset($data);
         if ($xmlResult) {
             $this->subscriptions = $zf_opmlItems;
             unset($zf_opmlItems);
         } else {
             $this->lastError = "Error parsing subscriptions file <br />error: {$xmlError} at line: {$xmlCrtline}";
             zf_debug("{$xmlError} at line: {$xmlCrtline}", DBG_OPML);
             return false;
         }
     } else {
         $this->lastError = 'Error opening the subscriptions file!';
         return false;
     }
     $this->_sanitize();
     return true;
 }
开发者ID:mm999,项目名称:zebrafeeds,代码行数:33,代码来源:subscriptionstorage.php

示例15: go

 /**
  * Run the loader, to load up field-restrictions from the XML file.
  *
  * @param  string			The default breadcrumbs
  * @param  string			The breadcrumb XML data
  */
 function go($current_breadcrumbs, $data)
 {
     $this->tag_stack = array();
     $this->attribute_stack = array();
     $this->substitution_current_match_key = NULL;
     $this->substitution_current_label = NULL;
     $this->links = array();
     $this->substitutions = array();
     $breadcrumb_tpl = do_template('BREADCRUMB_ESCAPED');
     $this->breadcrumb_tpl = $breadcrumb_tpl->evaluate();
     $this->current_breadcrumbs = $current_breadcrumbs;
     // Create and setup our parser
     $xml_parser = @xml_parser_create();
     if ($xml_parser === false) {
         return;
         // PHP5 default build on windows comes with this function disabled, so we need to be able to escape on error
     }
     xml_set_object($xml_parser, $this);
     @xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, get_charset());
     @xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($xml_parser, 'startElement', 'endElement');
     xml_set_character_data_handler($xml_parser, 'startText');
     // Run the parser
     if (@xml_parse($xml_parser, $data, true) == 0) {
         attach_message('breadcrumbs.xml: ' . xml_error_string(xml_get_error_code($xml_parser)), 'warn');
         return;
     }
     @xml_parser_free($xml_parser);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:35,代码来源:breadcrumbs.php


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