• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xml_set_end_namespace_decl_handler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parse

 function parse()
 {
     set_error_handler(array(&$this, 'error_handler'));
     array_unshift($this->ns_contexts, array());
     $parser = xml_parser_create_ns();
     xml_set_object($parser, $this);
     xml_set_element_handler($parser, "start_element", "end_element");
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
     xml_set_character_data_handler($parser, "cdata");
     xml_set_default_handler($parser, "_default");
     xml_set_start_namespace_decl_handler($parser, "start_ns");
     xml_set_end_namespace_decl_handler($parser, "end_ns");
     $this->content = '';
     $ret = true;
     $fp = fopen($this->FILE, "r");
     while ($data = fread($fp, 4096)) {
         if ($this->debug) {
             $this->content .= $data;
         }
         if (!xml_parse($parser, $data, feof($fp))) {
             trigger_error(sprintf(__('XML error: %s at line %d') . "\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
             $ret = false;
             break;
         }
     }
     fclose($fp);
     xml_parser_free($parser);
     restore_error_handler();
     return $ret;
 }
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:31,代码来源:atomlib.php


示例2: XhldXmlAtomParser

 function XhldXmlAtomParser($input)
 {
     $this->parser = xml_parser_create('UTF-8');
     xml_set_object($this->parser, $this);
     $this->input =& $input;
     $this->setCaseFolding(true);
     $this->useUtfEncoding();
     $this->_parent[0] = '';
     xml_set_element_handler($this->parser, "atom_start_element", "atom_end_element");
     xml_set_character_data_handler($this->parser, "atom_character_data");
     xml_set_start_namespace_decl_handler($this->parser, "atom_ns_start");
     xml_set_end_namespace_decl_handler($this->parser, "atom_ns_end");
 }
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:13,代码来源:xmlatomparser.php


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


示例4: register

 /**
  *  Register this class with a parser
  *
  *  @param string $namespace (optional)
  *  @param string $encoding (optional) default into to autodetect based on env
  *  @param string $separator (optional) the seperator to use for namespace
  *  @return resource the parser
  */
 public function register($encoding = '', $namespace = false, $separator = null)
 {
     if ($this->parser === null) {
         if ($namespace !== null) {
             $this->parser = xml_parser_create_ns($encoding, $separator);
         } else {
             $this->parser = xml_parser_create($encoding);
         }
         if (!$this->parser) {
             throw new RegisterParserFailure('call to xml_parser_create() failed');
         }
         # set element handler
         xml_set_element_handler($this->parser, array($this, "xmlStartTag"), array($this, "xmlEndTag"));
         # set CDATA hander
         xml_set_character_data_handler($this->parser, array($this, "xmlTagContent"));
         # set processing instructions handler
         xml_set_processing_instruction_handler($this->parser, array($this, "xmlPI"));
         # set the unparsed entity declaration handler
         xml_set_unparsed_entity_decl_handler($this->parser, array($this, "xmlUnparsedEntity"));
         # set the notation declaration handler function
         xml_set_notation_decl_handler($this->parser, array($this, "xmlNotation"));
         # set the external entity reference handler function
         xml_set_external_entity_ref_handler($this->parser, array($this, "xmlEentityRef"));
         # Sets the default handler function
         xml_set_default_handler($this->parser, array($this, "xmlDefault"));
         # Set a handler to be called when a namespace is declared.
         xml_set_start_namespace_decl_handler($this->parser, array($this, "xmlNSStart"));
         # Set a handler to be called when leaving the scope of a namespace declaration
         xml_set_end_namespace_decl_handler($this->parser, array($this, "xmlNSEnd"));
         # turn off case folding to stop element names from being uppercased;
         $this->setOption(XML_OPTION_CASE_FOLDING, false);
         //$this->setOption(XML_OPTION_SKIP_WHITE, true);
     } else {
         throw new ParserException('Parser already registered call XML::unregister() first');
     }
     return $this->parser;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:45,代码来源:XML.php


示例5: register

 /**
  *
  * @access protected
  */
 function register()
 {
     xml_set_character_data_handler($this->parser, 'character_data');
     xml_set_default_handler($this->parser, 'default_data');
     xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
     xml_set_end_namespace_decl_handler($this->parser, 'end_namespace_decl');
     xml_set_external_entity_ref_handler($this->parser, 'external_entity_ref');
     xml_set_notation_decl_handler($this->parser, 'notation_decl');
     xml_set_processing_instruction_handler($this->parser, 'processing_instruction');
     xml_set_start_namespace_decl_handler($this->parser, 'start_namespace_decl');
     xml_set_unparsed_entity_decl_handler($this->parser, 'unparsed_entity');
     return $this->registered = 1;
 }
开发者ID:jnvilo,项目名称:tomasinasanctuary.org,代码行数:17,代码来源:IsterXmlExpat.php


示例6: SimplePie_Parser

 function SimplePie_Parser($data, $encoding, $return_xml = false)
 {
     $this->encoding = $encoding;
     // Strip BOM:
     // UTF-32 Big Endian BOM
     if (strpos($data, sprintf('%c%c%c%c', 0x0, 0x0, 0xfe, 0xff)) === 0) {
         $data = substr($data, 4);
     } else {
         if (strpos($data, sprintf('%c%c%c%c', 0xff, 0xfe, 0x0, 0x0)) === 0) {
             $data = substr($data, 4);
         } else {
             if (strpos($data, sprintf('%c%c', 0xfe, 0xff)) === 0) {
                 $data = substr($data, 2);
             } else {
                 if (strpos($data, sprintf('%c%c', 0xff, 0xfe)) === 0) {
                     $data = substr($data, 2);
                 } else {
                     if (strpos($data, sprintf('%c%c%c', 0xef, 0xbb, 0xbf)) === 0) {
                         $data = substr($data, 3);
                     }
                 }
             }
         }
     }
     // Make sure the XML prolog is sane and has the correct encoding
     if (preg_match('/^<\\?xml(.*)?>/msiU', $data, $prolog)) {
         $data = substr_replace($data, '', 0, strlen($prolog[0]));
     }
     $data = "<?xml version='1.0' encoding='{$encoding}'?>\n" . $data;
     // Put some data into CDATA blocks
     // If we're RSS
     if ((stristr($data, '<rss') || preg_match('/<([a-z0-9]+\\:)?RDF/mi', $data)) && (preg_match('/<([a-z0-9]+\\:)?channel/mi', $data) || preg_match('/<([a-z0-9]+\\:)?item/mi', $data))) {
         $sp_elements = array('author', 'category', 'copyright', 'description', 'docs', 'generator', 'guid', 'language', 'lastBuildDate', 'link', 'managingEditor', 'pubDate', 'title', 'url', 'webMaster');
     } else {
         $sp_elements = array('content', 'copyright', 'name', 'subtitle', 'summary', 'tagline', 'title');
     }
     foreach ($sp_elements as $full) {
         $data = preg_replace_callback("/<({$full})((\\s*((\\w+:)?\\w+)\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))*)\\s*(\\/>|>(.*)<\\/{$full}>)/msiU", array(&$this, 'add_cdata'), $data);
     }
     foreach ($sp_elements as $full) {
         // Deal with CDATA within CDATA (this can be caused by us inserting CDATA above)
         $data = preg_replace_callback("/<({$full})((\\s*((\\w+:)?\\w+)\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))*)\\s*(\\/>|><!\\[CDATA\\[(.*)\\]\\]><\\/{$full}>)/msiU", array(&$this, 'cdata_in_cdata'), $data);
     }
     // Return the XML, if so desired
     if ($return_xml) {
         $this->data =& $data;
         return;
     }
     // Create the parser
     $this->xml = xml_parser_create_ns($encoding);
     xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1);
     xml_set_object($this->xml, $this);
     xml_set_character_data_handler($this->xml, 'data_handler');
     xml_set_element_handler($this->xml, 'start_handler', 'end_handler');
     xml_set_start_namespace_decl_handler($this->xml, 'start_name_space');
     xml_set_end_namespace_decl_handler($this->xml, 'end_name_space');
     // Parse!
     if (!xml_parse($this->xml, $data)) {
         $this->data = null;
         $this->error_code = xml_get_error_code($this->xml);
         $this->error_string = xml_error_string($this->error_code);
     }
     $this->current_line = xml_get_current_line_number($this->xml);
     $this->current_column = xml_get_current_column_number($this->xml);
     $this->current_byte = xml_get_current_byte_index($this->xml);
     xml_parser_free($this->xml);
     return;
 }
开发者ID:jbogota,项目名称:blog-king,代码行数:68,代码来源:class-simplepie-rss.php


示例7: xml_set_end_namespace_decl_handler

<?php

/* Prototype  : proto int xml_set_end_namespace_decl_handler(resource parser, string hdl)
 * Description: Set up character data handler 
 * Source code: ext/xml/xml.c
 * Alias to functions: 
 */
echo "*** Testing xml_set_end_namespace_decl_handler() : error conditions ***\n";
//Test xml_set_end_namespace_decl_handler with one more than the expected number of arguments
echo "\n-- Testing xml_set_end_namespace_decl_handler() function with more than expected no. of arguments --\n";
$hdl = 'string_val';
$extra_arg = 10;
var_dump(xml_set_end_namespace_decl_handler(null, $hdl, $extra_arg));
// Testing xml_set_end_namespace_decl_handler with one less than the expected number of arguments
echo "\n-- Testing xml_set_end_namespace_decl_handler() function with less than expected no. of arguments --\n";
var_dump(xml_set_end_namespace_decl_handler(null));
echo "Done";
开发者ID:badlamer,项目名称:hhvm,代码行数:17,代码来源:xml_set_end_namespace_decl_handler_error.php


示例8: init


//.........这里部分代码省略.........
                     case 'cp1258':
                     case 'windows-1258':
                     case '1258':
                         $encoding = 'Windows-1258';
                         $use_iconv = true;
                         break;
                         // Default to UTF-8
                     // Default to UTF-8
                     default:
                         $encoding = 'UTF-8';
                         break;
                 }
             } else {
                 $mp_rss = preg_replace('/<\\?xml(.*)( standalone="no")(.*)\\?>/msiU', '<?xml\\1\\3?>', $mp_rss, 1);
                 $mp_rss = preg_replace('/<\\?xml(.*)\\?>/msiU', '<?xml\\1 encoding="UTF-8"?>', $mp_rss, 1);
                 preg_match('/encoding=["|\'](.*)["|\']/Ui', $mp_rss, $match);
                 $use_iconv = true;
                 $use_mbstring = true;
                 $utf8_fail = false;
                 $encoding = 'UTF-8';
             }
             $this->encoding = $encoding;
             // If function is available and able, convert characters to UTF-8, and overwrite $this->encoding
             if (function_exists('iconv') && $use_iconv && iconv($encoding, 'UTF-8', $mp_rss)) {
                 $mp_rss = iconv($encoding, 'UTF-8//TRANSLIT', $mp_rss);
                 $mp_rss = str_replace($match[0], 'encoding="UTF-8"', $mp_rss);
                 $this->encoding = 'UTF-8';
             } else {
                 if (function_exists('mb_convert_encoding') && $use_mbstring) {
                     $mp_rss = mb_convert_encoding($mp_rss, 'UTF-8', $encoding);
                     $mp_rss = str_replace($match[0], 'encoding="UTF-8"', $mp_rss);
                     $this->encoding = 'UTF-8';
                 } else {
                     if (($use_mbstring || $use_iconv) && $utf8_fail) {
                         $this->encoding = 'UTF-8';
                         $mp_rss = str_replace($match[0], 'encoding="UTF-8"', $mp_rss);
                     }
                 }
             }
             $mp_rss = preg_replace('/<(.*)>[\\s]*<\\!\\[CDATA\\[/msiU', '<\\1 spencoded="false"><![CDATA[', $mp_rss);
             // Add an internal attribute to CDATA sections
             $mp_rss = str_replace(']] spencoded="false">', ']]>', $mp_rss);
             // Remove it when we're on the end of a CDATA block (therefore making it ill-formed)
             // If we're RSS
             if (preg_match('/<rdf:rdf/i', $mp_rss) || preg_match('/<rss/i', $mp_rss)) {
                 $sp_elements = array('author', 'link');
                 // Or if we're Atom
             } else {
                 $sp_elements = array('content', 'copyright', 'name', 'subtitle', 'summary', 'tagline', 'title');
             }
             foreach ($sp_elements as $full) {
                 // The (<\!\[CDATA\[)? never matches any CDATA block, therefore the CDATA gets added, but never replaced
                 $mp_rss = preg_replace("/<{$full}(.*)>[\\s]*(<\\!\\[CDATA\\[)?(.*)(]]>)?[\\s]*<\\/{$full}>/msiU", "<{$full}\\1><![CDATA[\\3]]></{$full}>", $mp_rss);
                 // The following line is a work-around for the above bug
                 $mp_rss = preg_replace("/<{$full}(.*)><\\!\\[CDATA\\[[\\s]*<\\!\\[CDATA\\[/msiU", "<{$full}\\1><![CDATA[", $mp_rss);
                 // Deal with CDATA within CDATA (this can be caused by us inserting CDATA above)
                 $mp_rss = preg_replace_callback("/<({$full})(.*)><!\\[CDATA\\[(.*)\\]\\]><\\/{$full}>/msiU", array(&$this, 'cdata_in_cdata'), $mp_rss);
             }
             // If XML Dump is enabled, send feed to the page and quit.
             if ($this->xml_dump) {
                 header("Content-type: text/xml; charset=" . $this->encoding);
                 echo $mp_rss;
                 exit;
             }
             $this->xml = xml_parser_create_ns($this->encoding);
             $this->namespaces = array('xml' => 'HTTP://WWW.W3.ORG/XML/1998/NAMESPACE', 'atom' => 'ATOM', 'rss2' => 'RSS', 'rdf' => 'RDF', 'rss1' => 'RSS', 'dc' => 'DC', 'xhtml' => 'XHTML', 'content' => 'CONTENT');
             xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1);
             xml_set_object($this->xml, $this);
             xml_set_character_data_handler($this->xml, 'dataHandler');
             xml_set_element_handler($this->xml, 'startHandler', 'endHandler');
             xml_set_start_namespace_decl_handler($this->xml, 'startNameSpace');
             xml_set_end_namespace_decl_handler($this->xml, 'endNameSpace');
             if (xml_parse($this->xml, $mp_rss)) {
                 xml_parser_free($this->xml);
                 $this->parse_xml_data_array();
                 $this->data['feedinfo']['encoding'] = $this->encoding;
                 if ($this->order_by_date && !empty($this->data['items'])) {
                     usort($this->data['items'], create_function('$a,$b', 'if ($a->date == $b->date) return 0; return ($a->date < $b->date) ? 1 : -1;'));
                 }
                 if ($this->caching && substr($this->rss_url, 0, 7) == 'http://') {
                     if ($this->is_writeable_createable($cache_filename)) {
                         $fp = fopen($cache_filename, 'w');
                         fwrite($fp, serialize($this->data));
                         fclose($fp);
                     } else {
                         trigger_error("{$cache_filename} is not writeable", E_USER_WARNING);
                     }
                 }
                 return true;
             } else {
                 $this->sp_error(sprintf('XML error: %s at line %d, column %d', xml_error_string(xml_get_error_code($this->xml)), xml_get_current_line_number($this->xml), xml_get_current_column_number($this->xml)), E_USER_WARNING, __FILE__, __LINE__);
                 xml_parser_free($this->xml);
                 $this->data = array();
                 return false;
             }
         }
     } else {
         return false;
     }
 }
开发者ID:qlixes,项目名称:springphp,代码行数:101,代码来源:simplepie.php


示例9: _initParser

 /**
  * @internal
  * Init the XML parser
  * @param $ns
  * @param $encoding
  * @param $separator
  * @private
  */
 function _initParser($ns = false, $encoding = 'UTF-8', $separator = null)
 {
     $this->_p = $ns ? xml_parser_create_ns($encoding, $separator) : xml_parser_create($encoding);
     xml_set_object($this->_p, $this);
     xml_set_default_handler($this->_p, '_default');
     xml_set_element_handler($this->_p, '_tagOpen', '_tagClose');
     xml_set_character_data_handler($this->_p, '_cdata');
     xml_set_start_namespace_decl_handler($this->_p, '_nsStart');
     xml_set_end_namespace_decl_handler($this->_p, '_nsEnd');
     xml_set_external_entity_ref_handler($this->_p, '_entityRef');
     xml_set_processing_instruction_handler($this->_p, '_pi');
     xml_set_notation_decl_handler($this->_p, '_notation');
     xml_set_unparsed_entity_decl_handler($this->_p, '_unparsedEntity');
     $this->setOption(XML_OPTION_CASE_FOLDING, false);
 }
开发者ID:09060906,项目名称:CakePHP-Payment-Plugin,代码行数:23,代码来源:sofortLib.php


示例10: Aspis_xml_set_end_namespace_decl_handler

function Aspis_xml_set_end_namespace_decl_handler($parser, $handler)
{
    global $Aspis_xml_objects;
    if (!empty($Aspis_xml_objects)) {
        $c = count($Aspis_xml_objects);
        for ($i = $c - 1; $i >= 0; $i--) {
            $e = $Aspis_xml_objects[$i];
            if ($e[0] === $parser[0]) {
                $handler[0] = AspisInternalCallback(array(array(array($e[1], false), array($handler[0], false)), false));
                break;
            }
        }
    }
    return array(xml_set_end_namespace_decl_handler($parser[0], $handler[0]), false);
}
开发者ID:NetPainter,项目名称:aspis,代码行数:15,代码来源:AspisLibrary.php


示例11: xml_parser_create_ns

/* Prototype  : bool xml_set_start_namespace_decl_handler  ( resource $parser  , callback $handler  )
 * Description: Set up start namespace declaration handler.
 * Source code: ext/xml/xml.c
 * Alias to functions: 
 */
$xml = <<<HERE
<aw1:book xmlns:aw1="http://www.somewhere.com/namespace1"
          xmlns:aw2="file:/DTD/somewhere.dtd">
<aw1:para>Any old text.</aw1:para>
<aw2:td>An HTML table cell.</aw2:td>
</aw1:book>
HERE;
$parser = xml_parser_create_ns();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
var_dump(xml_set_start_namespace_decl_handler($parser, "Namespace_Start_Handler"));
var_dump(xml_set_end_namespace_decl_handler($parser, "Namespace_End_Handler"));
xml_parse($parser, $xml, true);
xml_parser_free($parser);
echo "Done\n";
function Namespace_Start_Handler($parser, $prefix, $uri)
{
    echo "Namespace_Start_Handler called\n";
    echo "...Prefix: " . $prefix . "\n";
    echo "...Uri: " . $uri . "\n";
}
function Namespace_End_Handler($parser, $prefix)
{
    echo "Namespace_End_Handler called\n";
    echo "...Prefix: " . $prefix . "\n\n";
}
function DefaultHandler($parser, $data)
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:xml_set_start_namespace_decl_handler_basic.php


示例12: rss

 /**
  * Constructs the RSS reader: downloads the URL and parses it. Check $error after constructing.
  *
  * @param  URLPATH		The URL to the RSS we will be reading
  * @param  boolean		Whether the 'url' is actually a filesystem path
  */
 function rss($url, $is_filesystem_path = false)
 {
     require_lang('rss');
     $this->namespace_stack = array();
     $this->tag_stack = array();
     $this->attribute_stack = array();
     $this->gleamed_feed = array();
     $this->gleamed_items = array();
     $this->feed_url = $url;
     $this->error = NULL;
     if (!function_exists('xml_parser_create')) {
         $this->error = do_lang_tempcode('XML_NEEDED');
         return;
     }
     if (!$is_filesystem_path && url_is_local($url)) {
         $url = get_custom_base_url() . '/' . $url;
     }
     //echo $url;exit();
     if ($is_filesystem_path) {
         $GLOBALS['HTTP_CHARSET'] = '';
         $data = @file_get_contents($url);
     } else {
         $GLOBALS['HTTP_CHARSET'] = '';
         $data = http_download_file($url, NULL, false);
         //				if (!is_null($data)) break;
     }
     if (is_null($data)) {
         $this->error = do_lang('RSS_XML_MISSING', $url) . ' [' . $GLOBALS['HTTP_MESSAGE'] . ']';
     } else {
         // Try and detect feed charset
         $exp = '#<\\?xml\\s+version\\s*=\\s*["\'][\\d\\.]+["\']\\s*(encoding\\s*=\\s*["\']([^"\'<>]+)["\'])?\\s*(standalone\\s*=\\s*["\']([^"\'<>]+)["\'])?\\s*\\?' . '>#';
         $matches = array();
         if (preg_match($exp, $data, $matches) != 0 && array_key_exists(2, $matches)) {
             $GLOBALS['HTTP_CHARSET'] = $matches[2];
             if (strtolower($GLOBALS['HTTP_CHARSET']) == 'windows-1252') {
                 $GLOBALS['HTTP_CHARSET'] = 'ISO-8859-1';
             }
         }
         // Weed out if isn't supported
         if (is_null($GLOBALS['HTTP_CHARSET']) || !in_array(strtoupper($GLOBALS['HTTP_CHARSET']), array('ISO-8859-1', 'US-ASCII', 'UTF-8'))) {
             $GLOBALS['HTTP_CHARSET'] = 'UTF-8';
         }
         // Our internal charset
         $parser_charset = get_charset();
         if (!in_array(strtoupper($parser_charset), array('ISO-8859-1', 'US-ASCII', 'UTF-8'))) {
             $parser_charset = 'UTF-8';
         }
         // Create and setup our parser
         $xml_parser = function_exists('xml_parser_create_ns') ? @xml_parser_create_ns($GLOBALS['HTTP_CHARSET']) : @xml_parser_create($GLOBALS['HTTP_CHARSET']);
         if ($xml_parser === false) {
             $this->error = do_lang_tempcode('XML_PARSING_NOT_SUPPORTED');
             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, $parser_charset);
         xml_set_element_handler($xml_parser, 'startElement', 'endElement');
         xml_set_character_data_handler($xml_parser, 'startText');
         //xml_set_external_entity_ref_handler($xml_parser,'extEntity');
         if (function_exists('xml_set_start_namespace_decl_handler')) {
             xml_set_start_namespace_decl_handler($xml_parser, 'startNamespace');
         }
         if (function_exists('xml_set_end_namespace_decl_handler')) {
             xml_set_end_namespace_decl_handler($xml_parser, 'endNameSpace');
         }
         //$data=convert_to_internal_encoding($data);		xml_parser does it for us, and we can't disable it- so run with it instead of our own. Shame as it's inferior.
         if (strpos($data, '<!ENTITY') === false) {
             $extra_data = "<" . "?xml version=\"1.0\" encoding=\"" . $GLOBALS['HTTP_CHARSET'] . "\" ?" . ">\n<!DOCTYPE atom [\n<!ENTITY nbsp \" \" >\n]>\n";
             $data = preg_replace($exp, $extra_data, trim($data));
             if ($extra_data != '' && strpos($data, $extra_data) === false) {
                 $data = $extra_data . $data;
             }
             if (strtoupper($GLOBALS['HTTP_CHARSET']) == 'ISO-8859-1' || strtoupper($GLOBALS['HTTP_CHARSET']) == 'UTF-8') {
                 $table = array_flip(get_html_translation_table(HTML_ENTITIES));
                 if (strtoupper($GLOBALS['HTTP_CHARSET']) == 'UTF-8') {
                     foreach ($table as $x => $y) {
                         $table[$x] = utf8_encode($y);
                     }
                 }
                 unset($table['&amp;']);
                 unset($table['&gt;']);
                 unset($table['&lt;']);
                 $data = strtr($data, $table);
             }
             $convert_bad_entities = true;
         } else {
             $convert_bad_entities = false;
             if (strpos($data, "<" . "?xml") === false) {
                 $data = "<" . "?xml version=\"1.0\" encoding=\"" . $GLOBALS['HTTP_CHARSET'] . "\" ?" . ">" . $data;
             }
             $data = preg_replace($exp, "<" . "?xml version=\"1.0\" encoding=\"" . $GLOBALS['HTTP_CHARSET'] . "\" ?" . ">", $data);
             // Strip out internal encoding (we already detected and sanitised it)
         }
         $data = unixify_line_format($data, $GLOBALS['HTTP_CHARSET']);
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:rss.php


示例13: xml_set_end_namespace_decl_handler

 * Description: Set up character data handler 
 * Source code: ext/xml/xml.c
 * Alias to functions: 
 */
echo "*** Testing xml_set_end_namespace_decl_handler() : usage variations ***\n";
error_reporting(E_ALL & ~E_NOTICE);
class aClass
{
    function __toString()
    {
        return "Some Ascii Data";
    }
}
function validHandler(resource $parser, string $data)
{
}
// Initialise function arguments not being substituted (if any)
$hdl = 'validHandler';
//get an unset variable
$unset_var = 10;
unset($unset_var);
$fp = fopen(__FILE__, "r");
//array of values to iterate over
$values = array(0, 1, 12345, -2345, 10.5, -10.5, 101234567000.0, 1.07654321E-9, 0.5, array(), array(0), array(1), array(1, 2), array('color' => 'red', 'item' => 'pen'), NULL, null, true, false, TRUE, FALSE, "", '', "string", 'string', new aClass(), $fp, $undefined_var, $unset_var);
// loop through each element of the array for parser
foreach ($values as $value) {
    echo @"\nArg value {$value} \n";
    var_dump(xml_set_end_namespace_decl_handler($value, $hdl));
}
fclose($fp);
echo "Done";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:xml_set_end_namespace_decl_handler_variation1.php


示例14: resetParser

 /**
  * Resets internal XML Parser instance
  */
 protected function resetParser()
 {
     if (is_resource($this->parser)) {
         xml_parser_free($this->parser);
         $this->parser = null;
     }
     $this->documentNode = null;
     $this->nodeStack = array(new $this->params['nodeClass'](VIVVO_XML_DOCUMENT_NODE));
     $this->parser = xml_parser_create($this->params['encoding']);
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($this->parser, array(&$this, 'handlerNodeStart'), array(&$this, 'handlerNodeEnd'));
     xml_set_character_data_handler($this->parser, array(&$this, 'handlerTextNode'));
     xml_set_default_handler($this->parser, array(&$this, 'handlerDefault'));
     xml_set_end_namespace_decl_handler($this->parser, false);
     xml_set_external_entity_ref_handler($this->parser, false);
     xml_set_notation_decl_handler($this->parser, false);
     xml_set_processing_instruction_handler($this->parser, false);
     xml_set_start_namespace_decl_handler($this->parser, false);
     xml_set_unparsed_entity_decl_handler($this->parser, false);
     VivvoXMLNode::$counter = 0;
 }
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:25,代码来源:vivvoxml.php


示例15: parse

 /**
  * Parses xml text using Expat
  * @param Object A reference to the DOM document that the xml is to be parsed into
  * @param string The text to be parsed
  * @param boolean True if CDATA Section nodes are not to be converted into Text nodes
  * @return boolean True if the parsing is successful
  */
 function parse(&$myXMLDoc, $xmlText, $preserveCDATA = true)
 {
     $this->xmlDoc =& $myXMLDoc;
     $this->lastChild =& $this->xmlDoc;
     $this->preserveCDATA = $preserveCDATA;
     //create instance of expat parser (should be included in php distro)
     if (version_compare(phpversion(), '5.0', '<=')) {
         if ($this->xmlDoc->isNamespaceAware) {
             $parser = xml_parser_create_ns('');
         } else {
             $parser = xml_parser_create('');
         }
     } else {
         if ($this->xmlDoc->isNamespaceAware) {
             $parser = xml_parser_create_ns();
         } else {
             $parser = xml_parser_create();
         }
     }
     //set handlers for SAX events
     xml_set_object($parser, $this);
     xml_set_character_data_handler($parser, 'dataElement');
     xml_set_default_handler($parser, 'defaultDataElement');
     xml_set_notation_decl_handler($parser, 'notationElement');
     xml_set_processing_instruction_handler($parser, 'processingInstructionElement');
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     if ($this->xmlDoc->isNamespaceAware) {
         xml_set_start_namespace_decl_handler($parser, 'startNamespaceDeclaration');
         xml_set_end_namespace_decl_handler($parser, 'endNamespaceDeclaration');
         xml_set_element_handler($parser, 'startElementNS', 'endElement');
         $this->namespaceURIMap[DOMIT_XML_NAMESPACE] = 'xml';
     } else {
         xml_set_element_handler($parser, 'startElement', 'endElement');
     }
     //parse out whitespace -  (XML_OPTION_SKIP_WHITE = 1 does not
     //seem to work consistently across versions of PHP and Expat
     $xmlText = eregi_replace('>' . "[[:space:]]+" . '<', '><', $xmlText);
     $success = xml_parse($parser, $xmlText);
     $this->xmlDoc->errorCode = xml_get_error_code($parser);
     $this->xmlDoc->errorString = xml_error_string($this->xmlDoc->errorCode);
     xml_parser_free($parser);
     return $success;
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:51,代码来源:xml_domit_parser.php


示例16: NewsRss_Parser

 function NewsRss_Parser($data, $encoding, $return_xml = false)
 {
     $this->encoding = $encoding;
     if (strpos($data, sprintf('%c%c%c%c', 0x0, 0x0, 0xfe, 0xff)) === 0) {
         $data = substr($data, 4);
     } else {
         if (strpos($data, sprintf('%c%c%c%c', 0xff, 0xfe, 0x0, 0x0)) === 0) {
             $data = substr($data, 4);
         } else {
             if (strpos($data, sprintf('%c%c', 0xfe, 0xff)) === 0) {
                 $data = substr($data, 2);
             } else {
                 if (strpos($data, sprintf('%c%c', 0xff, 0xfe)) === 0) {
                     $data = substr($data, 2);
                 } else {
                     if (strpos($data, sprintf('%c%c%c', 0xef, 0xbb, 0xbf)) === 0) {
                         $data = substr($data, 3);
                     }
                 }
             }
         }
     }
     if (preg_match('/^<\\?xml(.*)?>/msiU', $data, $prolog)) {
         $data = substr_replace($data, '', 0, strlen($prolog[0]));
     }
     $data = "<?xml version='1.0' encoding='{$encoding}'?>\n" . $data;
     if ((stristr($data, '<rss') || preg_match('/<([a-z0-9]+\\:)?RDF/mi', $data)) && (preg_match('/<([a-z0-9]+\\:)?channel/mi', $data) || preg_match('/<([a-z0-9]+\\:)?item/mi', $data))) {
         $sp_elements = array('author', 'category', 'copyright', 'description', 'docs', 'generator', 'guid', 'language', 'lastBuildDate', 'link', 'managingEditor', 'pubDate', 'title', 'url', 'webMaster');
     } else {
         $sp_elements = array('content', 'copyright', 'name', 'subtitle', 'summary', 'tagline', 'title');
     }
     foreach ($sp_elements as $full) {
         $data = preg_replace_callback("/<({$full})((\\s*((\\w+:)?\\w+)\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))*)\\s*(\\/>|>(.*)<\\/{$full}>)/msiU", array(&$this, 'add_cdata'), $data);
     }
     foreach ($sp_elements as $full) {
         $data = preg_replace_callback("/<({$full})((\\s*((\\w+:)?\\w+)\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))*)\\s*(\\/>|><!\\[CDATA\\[(.*)\\]\\]><\\/{$full}>)/msiU", array(&$this, 'cdata_in_cdata'), $data);
     }
     if ($return_xml) {
         $this->data =& $data;
         return;
     }
     $this->xml = xml_parser_create_ns($encoding);
     xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1);
     xml_set_object($this->xml, $this);
     xml_set_character_data_handler($this->xml, 'data_handler');
     xml_set_element_handler($this->xml, 'start_handler', 'end_handler');
     xml_set_start_namespace_decl_handler($this->xml, 'start_name_space');
     xml_set_end_namespace_decl_handler($this->xml, 'end_name_space');
     if (!xml_parse($this->xml, $data)) {
         $this->data = null;
         $this->error_code = xml_get_error_code($this->xml);
         $this->error_string = xml_error_string($this->error_code);
     }
     $this->current_line = xml_get_current_line_number($this->xml);
     $this->current_column = xml_get_current_column_number($this->xml);
     $this->current_byte = xml_get_current_byte_index($this->xml);
     xml_parser_free($this->xml);
     return;
 }
开发者ID:politik86,项目名称:test2,代码行数:59,代码来源:feed.php


示例17: parse

	function parse() {

		global $app_logging;
		array_unshift($this->ns_contexts, array());

		$parser = xml_parser_create_ns();
		xml_set_object($parser, $this);
		xml_set_element_handler($parser, "start_element", "end_element");
		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
		xml_set_character_data_handler($parser, "cdata");
		xml_set_default_handler($parser, "_default");
		xml_set_start_namespace_decl_handler($parser, "start_ns");
		xml_set_end_namespace_decl_handler($parser, "end_ns");

		$contents = "";

		$fp = fopen("php://input", "r");
		while(!feof($fp)) {
			$line = fgets($fp, 4096);
		 
			if($app_logging) $contents .= $line;

			if(!xml_parse($parser, $line)) {
				log_app("xml_parse_error", "line: $line");
				$this->error = sprintf(__('XML error: %s at line %d')."\n",
					xml_error_string(xml_get_error_code($xml_parser)),
					xml_get_current_line_number($xml_parser));
				log_app("xml_parse_error", $this->error);
				return false;
			}
		}
		fclose($fp);

		xml_parser_free($parser);

		log_app("AtomParser->parse()",trim($contents));

		return true;
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:wp-app.php


示例18: parse

 function parse()
 {
     set_error_handler(array(&$this, 'error_handler'));
     array_unshift($this->ns_contexts, array());
     if (!function_exists('xml_parser_create_ns')) {
         trigger_error(__("PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension."));
         return false;
     }
     $parser = xml_parser_create_ns();
     xml_set_object($parser, $this);
     xml_set_element_handler($parser, "start_element", "end_element");
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
     xml_set_character_data_handler($parser, "cdata");
     xml_set_default_handler($parser, "_default");
     xml_set_start_namespace_decl_handler($parser, "start_ns");
     xml_set_end_namespace_decl_handler($parser, "end_ns");
     $this->content = '';
     $ret = true;
     $fp = fopen($this->FILE, "r");
     while ($data = fread($fp, 4096)) {
         if ($this->debug) {
             $this->content .= $data;
         }
         if (!xml_parse($parser, $data, feof($fp))) {
             /* translators: 1: error message, 2: line number */
             trigger_error(sprintf(__('XML Error: %1$s at line %2$s') . "\n", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)));
             $ret = false;
             break;
         }
     }
     fclose($fp);
     xml_parser_free($parser);
     restore_error_handler();
     return $ret;
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:36,代码来源:atomlib.php


示例19: parse


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xml_set_external_entity_ref_handler函数代码示例发布时间:2022-05-23
下一篇:
PHP xml_set_element_handler函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap