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


PHP xml_set_processing_instruction_handler函数代码示例

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


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

示例1: __construct

 public function __construct($input, $maxDepth = 20)
 {
     if (!is_string($input)) {
         throw new XmlToArrayException('No valid input.');
     }
     $this->_maxDepth = $maxDepth;
     $XMLParser = xml_parser_create();
     xml_parser_set_option($XMLParser, XML_OPTION_SKIP_WHITE, false);
     xml_parser_set_option($XMLParser, XML_OPTION_CASE_FOLDING, false);
     xml_parser_set_option($XMLParser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
     xml_set_character_data_handler($XMLParser, array($this, '_contents'));
     xml_set_default_handler($XMLParser, array($this, '_default'));
     xml_set_element_handler($XMLParser, array($this, '_start'), array($this, '_end'));
     xml_set_external_entity_ref_handler($XMLParser, array($this, '_externalEntity'));
     xml_set_notation_decl_handler($XMLParser, array($this, '_notationDecl'));
     xml_set_processing_instruction_handler($XMLParser, array($this, '_processingInstruction'));
     xml_set_unparsed_entity_decl_handler($XMLParser, array($this, '_unparsedEntityDecl'));
     if (!xml_parse($XMLParser, $input, true)) {
         $errorCode = xml_get_error_code($XMLParser);
         $message = sprintf('%s. line: %d, char: %d' . ($this->_tagStack ? ', tag: %s' : ''), xml_error_string($errorCode), xml_get_current_line_number($XMLParser), xml_get_current_column_number($XMLParser) + 1, implode('->', $this->_tagStack));
         xml_parser_free($XMLParser);
         throw new XmlToArrayException($message, $errorCode);
     }
     xml_parser_free($XMLParser);
 }
开发者ID:rodhoff,项目名称:MNW,代码行数:25,代码来源:xml_to_array.php

示例2: AbstractSAXParser

 function AbstractSAXParser()
 {
     // create a parser
     $this->parserResource = xml_parser_create();
     if (isset($this->parserResource)) {
         // allowing object instance to use the xml parser
         xml_set_object($this->parserResource, $this);
         // set tag event handler
         xml_set_element_handler($this->parserResource, "startTagElement", "endTagElement");
         // set CDATA event handler
         xml_set_character_data_handler($this->parserResource, "cdataElement");
         // set processing instruction handler
         xml_set_processing_instruction_handler($this->parserResource, "instructionElement");
         // set undeclare entity
         xml_set_unparsed_entity_decl_handler($this->parserResource, "undeclaredEntityElement");
         // set notation delcaration handler
         xml_set_notation_decl_handler($this->parserResource, "notationDeclarationElement");
         // set external entity handler
         xml_set_external_entity_ref_handler($this->parserResource, "externalEntityElement");
         // seat default parser option
         xml_parser_set_option($this->parserResource, XML_OPTION_SKIP_WHITE, 1);
         xml_parser_set_option($this->parserResource, XML_OPTION_CASE_FOLDING, 0);
         xml_parser_set_option($this->parserResource, XML_OPTION_TARGET_ENCODING, 'UTF-8');
     }
 }
开发者ID:alexpagnoni,项目名称:jphp,代码行数:25,代码来源:AbstractSAXParser.php

示例3: parse

 function parse($data)
 {
     $parser = xml_parser_create();
     xml_set_object($parser, $this);
     xml_set_processing_instruction_handler($parser, "PIHandler");
     xml_parse($parser, $data, true);
     xml_parser_free($parser);
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:xml_set_processing_instruction_handler_basic.php

示例4: XMLParser

 function XMLParser()
 {
     $this->parser = xml_parser_create();
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, FALSE);
     xml_set_element_handler($this->parser, "startElementhandler", "endElementHandler");
     xml_set_character_data_handler($this->parser, "cdataHandler");
     xml_set_processing_instruction_handler($this->parser, "processingInstructionHandler");
     xml_set_default_handler($this->parser, "defaultHandler");
 }
开发者ID:nbtscommunity,项目名称:phpfnlib,代码行数:9,代码来源:xml.php

示例5: createParser

function createParser($filename)
{
    $fh = fopen($filename, 'r');
    $parser = xml_parser_create();
    xml_set_element_handler($parser, "startElement", "endElement");
    xml_set_character_data_handler($parser, "characterData");
    xml_set_processing_instruction_handler($parser, "processingInstruction");
    xml_set_default_handler($parser, "default");
    return array($parser, $fh);
}
开发者ID:JohnWSteill,项目名称:EdProjs,代码行数:10,代码来源:11-8.php

示例6: createXmlParser

 protected function createXmlParser($encoding = 'utf-8')
 {
     $xp = xml_parser_create($encoding);
     xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
     xml_parser_set_option($xp, XML_OPTION_SKIP_WHITE, true);
     xml_set_object($xp, $this);
     xml_set_element_handler($xp, 'handleElementStart', 'handleElementEnd');
     xml_set_character_data_handler($xp, 'handleCharacterData');
     xml_set_processing_instruction_handler($xp, 'handleProcessingInstruction');
     return $xp;
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:11,代码来源:Parser.php

示例7: __construct

 /**
  * Class constructor
  * 
  * @param   string  The path of the file to parse
  * @param   string  A prefix path to add to all 'src' and 'href' attributes, if relative
  * @param   string  The output charset (default is UTF-8)
  * @return  void
  */
 public function __construct($file, $charset = 'UTF-8')
 {
     // The charset must be uppercase
     $charset = strtoupper($charset);
     // Checks if the file exists
     if (!file_exists($file) || !is_file($file)) {
         // The file does not exist
         throw new Woops_Xml_Parser_Exception('The specified XML file (\'' . $file . '\') does not exist', Woops_Xml_Parser_Exception::EXCEPTION_NO_FILE);
     }
     // Checks if the file is readable
     if (!is_readable($file)) {
         // Cannot read the file
         throw new Woops_Xml_Parser_Exception('The specified XML file (\'' . $file . '\') is not readable', Woops_Xml_Parser_Exception::EXCEPTION_FILE_NOT_READABLE);
     }
     // Checks if the charset is supported
     if (!isset(self::$_charsets[$charset])) {
         // Unsupported charset
         throw new Woops_Xml_Parser_Exception('The specified charset (' . $charset . ') is not supported', Woops_Xml_Parser_Exception::EXCEPTION_INVALID_CHARSET);
     }
     // Creates an XML parser
     $this->_parser = xml_parser_create($charset);
     // Sets the current instance as the XML parser object
     xml_set_object($this->_parser, $this);
     // Disables case-folding
     xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
     // Sets the element handler methods
     xml_set_element_handler($this->_parser, '_startElementHandler', '_endElementHandler');
     // Sets the character data handler method
     xml_set_character_data_handler($this->_parser, '_characterDataHandler');
     // Sets the processing instruction handler method
     xml_set_processing_instruction_handler($this->_parser, '_processingInstructionHandler');
     // Sets the default data handler method
     xml_set_default_handler($this->_parser, '_defaultHandler');
     // Tries to open a file handler
     if ($fileHandler = fopen($file, 'r')) {
         // Reads data from the file
         while ($data = fread($fileHandler, 4096)) {
             // Tries to parse the data
             if (!xml_parse($this->_parser, $data, feof($fileHandler))) {
                 // Gets the error string and line number
                 $errorString = xml_error_string(xml_get_error_code($this->_parser));
                 $errorLine = xml_get_current_line_number($this->_parser);
                 // Throws an exception, as we have an XML error
                 throw new Woops_Xml_Parser_Exception('XML parser error: ' . $errorString . ' at line number ' . $errorLine, Woops_Xml_Parser_Exception::EXCEPTION_XML_PARSER_ERROR);
             }
         }
         // Closes the file handler
         fclose($fileHandler);
     }
     // Frees the parser
     xml_parser_free($this->_parser);
 }
开发者ID:Sect0R,项目名称:WOOPS,代码行数:60,代码来源:Parser.class.php

示例8: parse

 function parse($xml)
 {
     $this->node_list = array(0 => array('type' => 'start', 'children' => array()));
     $this->cur_nodeid = 0;
     $this->parser = xml_parser_create();
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
     xml_set_element_handler($this->parser, array(&$this, 'handle_element_open'), array(&$this, 'handle_element_close'));
     xml_set_character_data_handler($this->parser, array(&$this, 'handle_cdata'));
     xml_set_processing_instruction_handler($this->parser, array(&$this, 'handle_instruction'));
     xml_set_default_handler($this->parser, array(&$this, 'handle_default'));
     xml_parse($this->parser, $xml, true);
     xml_parser_free($this->parser);
     $this->parser = null;
     return $this->node_list;
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:16,代码来源:class_xml_dom.php

示例9: encode

 /**
  * Take the input $xml and turn it into WBXML. This is _not_ the
  * intended way of using this class. It is derived from
  * Contenthandler and one should use it as a ContentHandler and
  * produce the XML-structure with startElement(), endElement(),
  * and characters().
  *
  * @throws Horde_Xml_Wbxml_Exception
  */
 public function encode($xml)
 {
     // Create the XML parser and set method references.
     $this->_parser = xml_parser_create_ns($this->_charset);
     xml_set_object($this->_parser, $this);
     xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
     xml_set_element_handler($this->_parser, '_startElement', '_endElement');
     xml_set_character_data_handler($this->_parser, '_characters');
     xml_set_processing_instruction_handler($this->_parser, '');
     xml_set_external_entity_ref_handler($this->_parser, '');
     if (!xml_parse($this->_parser, $xml)) {
         throw new Horde_Xml_Wbxml_Exception(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);
     return $this->_output;
 }
开发者ID:horde,项目名称:horde,代码行数:25,代码来源:Encoder.php

示例10: SaxParser

 function SaxParser(&$input)
 {
     $this->level = 0;
     $this->parser = xml_parser_create('UTF-8');
     xml_set_object($this->parser, $this);
     $this->input =& $input;
     $this->setCaseFolding(false);
     $this->useUtfEncoding();
     xml_set_element_handler($this->parser, 'handleBeginElement', 'handleEndElement');
     xml_set_character_data_handler($this->parser, 'handleCharacterData');
     xml_set_processing_instruction_handler($this->parser, 'handleProcessingInstruction');
     xml_set_default_handler($this->parser, 'handleDefault');
     xml_set_unparsed_entity_decl_handler($this->parser, 'handleUnparsedEntityDecl');
     xml_set_notation_decl_handler($this->parser, 'handleNotationDecl');
     xml_set_external_entity_ref_handler($this->parser, 'handleExternalEntityRef');
 }
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:16,代码来源:saxparser.php

示例11: parse

 protected function parse($xmlData)
 {
     $this->parser = xml_parser_create();
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
     xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, 'onTagStart', 'onTagEnd');
     xml_set_character_data_handler($this->parser, 'onTagContent');
     xml_set_processing_instruction_handler($this->parser, "onPiHandler");
     xml_set_default_handler($this->parser, "onDefaultHandler");
     if (!xml_parse($this->parser, $xmlData)) {
         $xmlErroCode = xml_get_error_code($this->parser);
         $xmlErroString = xml_error_string($xmlErroCode);
         $xmlLine = xml_get_current_line_number($this->parser);
         die(sprintf("XML error: %s at line %d", $xmlErroString, $xmlLine));
     }
     xml_parser_free($this->parser);
     $this->parser = NULL;
 }
开发者ID:kelsoncm,项目名称:phpage,代码行数:19,代码来源:Sax.php

示例12: init

 protected final function init()
 {
     if ($this instanceof Features\IXmlNamespaceParser) {
         $this->parser = xml_parser_create_ns('UTF-8');
         // Set up start namespace declaration handler
         xml_set_start_namespace_decl_handler($this->parser, 'ns_start');
         // Set up end namespace declaration handler
         xml_set_end_namespace_decl_handler($this->parser, 'ns_end');
     } elseif ($this instanceof Features\IXmlBasicParser) {
         $this->parser = xml_parser_create('UTF-8');
     } else {
         throw new \BadMethodCallException('This class does not implements the XML Parser capabilities. Please implement either IXmlBasicParser or IXmlNamespaceParser.');
     }
     xml_set_object($this->parser, $this);
     foreach ($this->options as $option => $value) {
         xml_parser_set_option($this->parser, $option, $value);
     }
     if ($this instanceof Features\IXmlProcessorParser) {
         // Set up processing instruction (PI) handler
         xml_set_processing_instruction_handler($this->parser, 'pi_handler');
     }
     if ($this instanceof Features\IXmlEntityHandler) {
         // Set up external entity reference handler
         xml_set_external_entity_ref_handler($this->parser, 'entity_handler');
     }
     if ($this instanceof Features\IXmlNdataHandler) {
         // Set up notation declaration handler
         xml_set_notation_decl_handler($this->parser, 'notation_handler');
         // Set up unparsed entity declaration handler
         xml_set_unparsed_entity_decl_handler($this->parser, 'ndata_handler');
     }
     xml_set_element_handler($this->parser, "element_start", "element_end");
     xml_set_character_data_handler($this->parser, "cdata_handler");
     if ($this instanceof Features\IXmlDefaultHandler) {
         if (!defined('ACTIVATE_XML_PARSER_DEFAULT_HANDLER_I_KNOW_WHAT_AM_I_DOING')) {
             trigger_error('Active default handler interferes with many XML features like internal parsable entities.', E_USER_WARNING);
         }
         // Set up default (fallback) handler.
         // Warning: Interferes with INTERNAL ENTITY declarations like
         // <!ENTITY a 'b'>
         xml_set_default_handler($this->parser, "default_handler");
     }
 }
开发者ID:anrdaemon,项目名称:library,代码行数:43,代码来源:XmlParser.php

示例13: runtest

 function runtest($num, $i)
 {
     $this->readfile($num);
     echo "parsing xml data file {$this->currentFile} iteration {$i}\n";
     $xml_parser = xml_parser_create();
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
     xml_set_object($xml_parser, $this);
     xml_set_element_handler($xml_parser, 'startElement', 'endElement');
     xml_set_character_data_handler($xml_parser, 'cDataHandler');
     xml_set_external_entity_ref_handler($xml_parser, 'externalEntityRefHandler');
     xml_set_processing_instruction_handler($xml_parser, 'piHandler');
     xml_set_unparsed_entity_decl_handler($xml_parser, 'unparsedEntityDeclHandler');
     xml_set_notation_decl_handler($xml_parser, 'entityDeclHandler');
     xml_set_default_handler($xml_parser, 'defaultHandler');
     if (!xml_parse($xml_parser, $this->contentBuffer, true)) {
         $this->currentFile != '' ? $inFile = "in file {$this->currentFile}" : ($inFile = '');
         $this->fatalErrorPage(sprintf(get_class($this) . ": XML error: %s at line %d {$inFile}", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
     }
     xml_parser_free($xml_parser);
 }
开发者ID:michaelprem,项目名称:phc,代码行数:20,代码来源:xmlparse.php

示例14: __construct

 function __construct($xml = '', $params = self::XML_ENCLOSE)
 {
     $this->_params = $params;
     if ($xml) {
         if ($this->_params & self::XML_ARRAY2XML_FORMAT) {
             $domDocument = new CMS_DOMDocument();
             $domDocument->loadXML($xml, 0, false, false);
             $this->_arrOutput = $this->_xml2Array($domDocument->documentElement, $domDocument->encoding);
         } else {
             $parser = xml_parser_create(APPLICATION_DEFAULT_ENCODING);
             xml_set_object($parser, $this);
             xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
             xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
             xml_set_element_handler($parser, "_tagOpen", "_tagClosed");
             xml_set_character_data_handler($parser, "_charData");
             xml_set_processing_instruction_handler($parser, "_piData");
             xml_set_default_handler($parser, "_tagData");
             //enclose with html tag
             if ($this->_params & self::XML_ENCLOSE) {
                 $xml = '<html>' . $xml . '</html>';
             }
             //add encoding declaration
             if ($this->_params ^ self::XML_DONT_ADD_XMLDECL) {
                 $xml = '<?xml version="1.0" encoding="' . APPLICATION_DEFAULT_ENCODING . '"?>' . "\n" . $xml;
             }
             if ($this->_params & self::XML_PROTECT_ENTITIES) {
                 $xml = $this->_codeEntities($xml);
             }
             if (!xml_parse($parser, $xml)) {
                 $this->_parsingError = sprintf("Parse error %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser));
                 if ($this->_params & ~self::XML_DONT_THROW_ERROR) {
                     $this->raiseError($this->_parsingError . " :\n" . $xml, true);
                 }
             }
             xml_parser_free($parser);
             unset($parser);
         }
     }
 }
开发者ID:davidmottet,项目名称:automne,代码行数:39,代码来源:xml2Array.php

示例15: __construct

 /**
  * Initializes the parser.
  *
  * The constructor method instantiates and configures the underlying XML
  * parser and its handlers.
  *
  * \param $encoding The character encoding to use for this parser. This
  * parameter is optional (defaults to null) and can be safely omitted. See
  * the PHP manual for xml_parser_create for more information about
  * encodings.
  */
 public function __construct($encoding = null)
 {
     $this->finalized = false;
     $this->cdata_buffer = array();
     $this->tags = array();
     /* Create the parser instance */
     if (is_null($encoding)) {
         $this->parser = xml_parser_create();
     } else {
         assert('is_string($encoding)');
         $this->parser = xml_parser_create($encoding);
     }
     /* Set some options */
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
     /* Always use UTF-8 */
     xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
     /* Setup the handlers */
     xml_set_element_handler($this->parser, array(&$this, 'start_element_handler'), array(&$this, 'end_element_handler'));
     xml_set_character_data_handler($this->parser, array(&$this, '_handle_data'));
     xml_set_processing_instruction_handler($this->parser, array(&$this, 'handle_pi'));
     xml_set_default_handler($this->parser, array(&$this, '_default_handler'));
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:34,代码来源:abstractxmlparser.lib.php


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