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


PHP xml_parser_create_ns函数代码示例

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


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

示例1: correct

 public function correct(string $input) : string
 {
     if (!mb_check_encoding($input, 'UTF-8')) {
         throw new SyntaxException(_('SVGファイルの符号化方式 (文字コード) は UTF-8 でなければなりません。'));
     }
     $parser = xml_parser_create_ns();
     $isValid = xml_parse_into_struct($parser, $input, $nodes);
     xml_parser_free($parser);
     if (!$isValid) {
         throw new SyntaxException(_('整形式になっていません。'));
     }
     $document = new \DOMDocument('1.0', 'UTF-8');
     $document->loadXML($input);
     // ノードの削除
     $root = $document->documentElement;
     foreach ((new \DOMXPath($document))->query(self::BLACKLIST) as $node) {
         if ($node === $root) {
             throw new SyntaxException(_('ルート要素がSVG名前空間に属していません。'));
         }
         $this->logger->error(sprintf(_('SVG中にノード %s を含めることはできません。'), $node->nodeName));
         if ($node->nodeType === XML_ATTRIBUTE_NODE) {
             $node->ownerElement->removeAttributeNode($node);
         } elseif ($node->parentNode) {
             $node->parentNode->removeChild($node);
         }
     }
     return $document->saveXML();
 }
开发者ID:esperecyan,项目名称:dictionary-php,代码行数:28,代码来源:SVGValidator.php

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

示例3: run

 /**
  * @param $fname
  */
 private function run($fname)
 {
     $parser = xml_parser_create_ns('UTF-8');
     // case folding violates XML standard, turn it off
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
     xml_set_element_handler($parser, array($this, 'rootElementOpen'), false);
     if (file_exists($fname)) {
         $file = fopen($fname, "rb");
         if ($file) {
             do {
                 $chunk = fread($file, 32768);
                 $ret = xml_parse($parser, $chunk, feof($file));
                 if ($ret == 0) {
                     // XML isn't well-formed!
                     fclose($file);
                     xml_parser_free($parser);
                     return;
                 }
             } while (!feof($file));
             fclose($file);
         }
     }
     $this->wellFormed = true;
     xml_parser_free($parser);
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:28,代码来源:XmlTypeCheck.php

示例4: 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,代码行数:32,代码来源:wp-app.php

示例5: _parse_propfind

 function _parse_propfind($path)
 {
     $this->success = true;
     $this->depth = 0;
     $this->props = array();
     $had_input = false;
     $xml_parser = xml_parser_create_ns("UTF-8", " ");
     xml_set_element_handler($xml_parser, array(&$this, "_startElement"), array(&$this, "_endElement"));
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
     $f_in = fopen($path, "r");
     while ($this->success && !feof($f_in)) {
         $line = fgets($f_in);
         if (is_string($line)) {
             $line = trim($line);
             if ($line == "") {
                 continue;
             }
             $had_input = true;
             $this->success &= xml_parse($xml_parser, $line, false);
         }
     }
     if ($had_input) {
         $this->success &= xml_parse($xml_parser, "", true);
     }
     fclose($f_in);
     xml_parser_free($xml_parser);
     if (!count($this->props)) {
         $this->props = "all";
     }
     // default
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:31,代码来源:_parse_propfind.php

示例6: _parse_lockinfo

 function _parse_lockinfo($path)
 {
     $this->success = true;
     $had_input = false;
     $xml_parser = xml_parser_create_ns("UTF-8", " ");
     xml_set_element_handler($xml_parser, array(&$this, "_startElement"), array(&$this, "_endElement"));
     xml_set_character_data_handler($xml_parser, array(&$this, "_data"));
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
     $f_in = fopen($path, "r");
     while ($this->success && !feof($f_in)) {
         $line = fgets($f_in);
         if (is_string($line)) {
             $line = trim($line);
             if ($line == "") {
                 continue;
             }
             $had_input = true;
             $this->success &= xml_parse($xml_parser, $line, false);
         }
     }
     if ($had_input) {
         $this->success &= xml_parse($xml_parser, "", true);
     }
     fclose($f_in);
     xml_parser_free($xml_parser);
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:26,代码来源:_parse_lockinfo.php

示例7: _parse_proppatch

 /**
  * constructor
  * 
  * @param  string  path of input stream 
  * @access public
  */
 function _parse_proppatch($path)
 {
     $this->success = true;
     $this->depth = 0;
     $this->props = array();
     $had_input = false;
     $f_in = fopen($path, "r");
     if (!$f_in) {
         $this->success = false;
         return;
     }
     $xml_parser = xml_parser_create_ns("UTF-8", " ");
     xml_set_element_handler($xml_parser, array(&$this, "_startElement"), array(&$this, "_endElement"));
     xml_set_character_data_handler($xml_parser, array(&$this, "_data"));
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
     while ($this->success && !feof($f_in)) {
         $line = fgets($f_in);
         if (is_string($line)) {
             $had_input = true;
             $this->success &= xml_parse($xml_parser, $line, false);
         }
     }
     if ($had_input) {
         $this->success &= xml_parse($xml_parser, "", true);
     }
     xml_parser_free($xml_parser);
     fclose($f_in);
 }
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:34,代码来源:_parse_proppatch.php

示例8: init

 function init() {
   $this->paths=Array(); 
   $this->parser = xml_parser_create_ns("",'^');
   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,"_data");
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:8,代码来源:pathparser.class.php

示例9: createParser

 function createParser()
 {
     $parser = xml_parser_create_ns(NULL, self::NS_SEPARATOR);
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, FALSE);
     xml_set_object($parser, $this);
     xml_set_element_handler($parser, 'startElement', 'endElement');
     xml_set_character_data_handler($parser, 'characterData');
     return $parser;
 }
开发者ID:litmanovitziv,项目名称:struct-reader,代码行数:9,代码来源:XMLFeed.php

示例10: HTTP_WebDAV_Client_parse_lock_response

 function HTTP_WebDAV_Client_parse_lock_response($response)
 {
     $xml_parser = xml_parser_create_ns("UTF-8", " ");
     xml_set_element_handler($xml_parser, array(&$this, "_startElement"), array(&$this, "_endElement"));
     xml_set_character_data_handler($xml_parser, array(&$this, "_data"));
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
     $this->success = xml_parse($xml_parser, $response, true);
     xml_parser_free($xml_parser);
 }
开发者ID:rrsc,项目名称:freemed,代码行数:9,代码来源:_parse_lock_response.php

示例11: comcode_xml_to_tempcode

 /**
  * Convert the specified comcode (text format) into a tempcode tree. You shouldn't output the tempcode tree to the browser, as it looks really horrible. If you are in a rare case where you need to output directly (not through templates), you should call the evaluate method on the tempcode object, to convert it into a string.
  *
  * @param  LONG_TEXT		The comcode to convert
  * @param  MEMBER			The member the evaluation is running as. This is a security issue, and you should only run as an administrator if you have considered where the comcode came from carefully
  * @param  ?integer		The position to conduct wordwrapping at (NULL: do not conduct word-wrapping)
  * @param  ?string		A special identifier that can identify this resource in a sea of our resources of this class; usually this can be ignored, but may be used to provide a binding between Javascript in evaluated comcode, and the surrounding environment (NULL: no explicit binding)
  * @param  object			The database connection to use
  * @param  boolean		Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block).
  * @param  boolean		Whether this is being pre-parsed, to pick up errors before row insertion.
  * @param  boolean		Whether to treat this whole thing as being wrapped in semihtml, but apply normal security otherwise.
  * @param  boolean		Whether we are only doing this parse to find the title structure
  * @param  boolean		Whether to only check the Comcode. It's best to use the check_comcode function which will in turn use this parameter.
  * @param  ?MEMBER		The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating)
  * @return tempcode		The tempcode tree.
  */
 function comcode_xml_to_tempcode($comcode, $source_member, $wrap_pos, $pass_id, $connection, $semiparse_mode, $preparse_mode, $is_all_semihtml, $structure_sweep, $check_only, $on_behalf_of_member = NULL)
 {
     if (is_null($pass_id)) {
         $pass_id = strval(mt_rand(0, 32000));
     }
     // This is a unique ID that refers to this specific piece of comcode
     $this->wml = false;
     // removed feature from ocPortal now
     $this->comcode = $comcode;
     $this->source_member = $source_member;
     $this->wrap_pos = $wrap_pos;
     $this->pass_id = $pass_id;
     $this->connection = $connection;
     $this->semiparse_mode = $semiparse_mode;
     $this->preparse_mode = $preparse_mode;
     $this->is_all_semihtml = $is_all_semihtml;
     $this->structure_sweep = $structure_sweep;
     $this->check_only = $check_only;
     $this->on_behalf_of_member = $on_behalf_of_member;
     global $VALID_COMCODE_TAGS, $IMPORTED_CUSTOM_COMCODE;
     if (!$IMPORTED_CUSTOM_COMCODE) {
         _custom_comcode_import($connection);
     }
     $this->namespace_stack = array();
     $this->tag_stack = array();
     $this->attribute_stack = array();
     $this->tempcode_stack = array(new ocp_tempcode());
     $this->special_child_elements_stack = array();
     // Create and setup our parser
     $xml_parser = function_exists('xml_parser_create_ns') ? xml_parser_create_ns() : xml_parser_create();
     if ($xml_parser === false) {
         return do_lang_tempcode('XML_PARSING_NOT_SUPPORTED');
         // 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');
     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, 'startNamespace');
     }
     $extra_data = "<?xml version=\"1.0\" encoding=\"" . escape_html(get_charset()) . "\" ?" . ">\n<!DOCTYPE comcode_xml [\n<!ENTITY nbsp \"&nbsp;\" >\n]>\n";
     if (xml_parse($xml_parser, $extra_data . $comcode, true) == 0) {
         $error_str = xml_error_string(xml_get_error_code($xml_parser));
         warn_exit(escape_html($error_str));
         // Parsing error
     } else {
         $this->tempcode = $this->tempcode_stack[0];
     }
     @xml_parser_free($xml_parser);
     return $this->tempcode;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:72,代码来源:comcode_xml.php

示例12: init_parser

 private function init_parser()
 {
     $this->depth = -1;
     $this->parser = xml_parser_create_ns("UTF-8", $this->delimiter);
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
     xml_set_character_data_handler($this->parser, array(&$this, "handle_character"));
     xml_set_element_handler($this->parser, array(&$this, "handle_start_tag"), array(&$this, "handle_end_tag"));
 }
开发者ID:lcandida,项目名称:push-message-serie-web,代码行数:10,代码来源:jaxl_xml_stream.php

示例13: xrds_parse

/**
 * Main entry point for parsing XRDS documents
 */
function xrds_parse($xml)
{
    global $xrds_services;
    $parser = xml_parser_create_ns();
    xml_set_element_handler($parser, '_xrds_element_start', '_xrds_element_end');
    xml_set_character_data_handler($parser, '_xrds_cdata');
    xml_parse($parser, $xml);
    xml_parser_free($parser);
    return $xrds_services;
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:13,代码来源:xrds.lib.php

示例14: OWLReader

 /**
  * Constructor
  */
 function OWLReader()
 {
     $this->root_tag = new OWLTag();
     $this->parser = xml_parser_create_ns();
     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
     //KARIM: removed & before "$this->root_tag" since it is not allowed in new versions of PHP
     xml_set_object($this->parser, $this->root_tag);
     xml_set_element_handler($this->parser, "startTag", "endTag");
     xml_set_character_data_handler($this->parser, "characters");
     xml_set_start_namespace_decl_handler($this->parser, "namespaceDecl");
 }
开发者ID:AhmedAMohamed,项目名称:qurananalysis,代码行数:14,代码来源:OWLReader.php

示例15: __construct

 function __construct($response)
 {
     $this->urls = array();
     $this->_depth = 0;
     $xml_parser = xml_parser_create_ns("UTF-8", " ");
     xml_set_element_handler($xml_parser, array($this, "_startElement"), array($this, "_endElement"));
     xml_set_character_data_handler($xml_parser, array($this, "_data"));
     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
     $this->success = xml_parse($xml_parser, $response, true);
     xml_parser_free($xml_parser);
     unset($this->_depth);
 }
开发者ID:samizdam,项目名称:HTTP_WebDAV_Client,代码行数:12,代码来源:_parse_propfind_response.php


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