本文整理汇总了PHP中xml_get_current_column_number函数的典型用法代码示例。如果您正苦于以下问题:PHP xml_get_current_column_number函数的具体用法?PHP xml_get_current_column_number怎么用?PHP xml_get_current_column_number使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xml_get_current_column_number函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* PHP5 constructor.
*/
function __construct($source)
{
# Check if PHP xml isn't compiled
#
if (!function_exists('xml_parser_create')) {
return trigger_error("PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension.");
}
$parser = xml_parser_create();
$this->parser = $parser;
# pass in parser, and a reference to this object
# set up handlers
#
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'feed_start_element', 'feed_end_element');
xml_set_character_data_handler($this->parser, 'feed_cdata');
$status = xml_parse($this->parser, $source);
if (!$status) {
$errorcode = xml_get_error_code($this->parser);
if ($errorcode != XML_ERROR_NONE) {
$xml_error = xml_error_string($errorcode);
$error_line = xml_get_current_line_number($this->parser);
$error_col = xml_get_current_column_number($this->parser);
$errormsg = "{$xml_error} at line {$error_line}, column {$error_col}";
$this->error($errormsg);
}
}
xml_parser_free($this->parser);
$this->normalize();
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:32,代码来源:rss.php
示例2: parseError
function parseError( $parser )
{
$error = xml_error_string( xml_get_error_code( $parser ) );
$errorLine = xml_get_current_line_number( $parser );
$errorColumn = xml_get_current_column_number( $parser );
return "<b>Error: $error at line $errorLine column $errorColumn</b>";
}
开发者ID:hoiwanjohnlouis,项目名称:eclipsePrototyping,代码行数:7,代码来源:xml_parser.php
示例3: formatMetadata
/**
* Format resource metadata.
*
* @param resource $value
*
* @return string
*/
protected function formatMetadata($value)
{
$props = array();
switch (get_resource_type($value)) {
case 'stream':
$props = stream_get_meta_data($value);
break;
case 'curl':
$props = curl_getinfo($value);
break;
case 'xml':
$props = array('current_byte_index' => xml_get_current_byte_index($value), 'current_column_number' => xml_get_current_column_number($value), 'current_line_number' => xml_get_current_line_number($value), 'error_code' => xml_get_error_code($value));
break;
}
if (empty($props)) {
return '{}';
}
$formatted = array();
foreach ($props as $name => $value) {
$formatted[] = sprintf('%s: %s', $name, $this->indentValue($this->presentSubValue($value)));
}
$template = sprintf('{%s%s%%s%s}', PHP_EOL, self::INDENT, PHP_EOL);
$glue = sprintf(',%s%s', PHP_EOL, self::INDENT);
return sprintf($template, implode($glue, $formatted));
}
开发者ID:GeorgeShazkho,项目名称:micros-de-conce,代码行数:32,代码来源:ResourcePresenter.php
示例4: error
function error($msg)
{
$errf = $this->error_func;
$line = xml_get_current_line_number($this->parser);
$col = xml_get_current_column_number($this->parser);
$errf("{$msg} at line:{$line}, col:{$col}.");
}
开发者ID:reddragon,项目名称:Online-Grading-System,代码行数:7,代码来源:problem.php
示例5: get_posts
function get_posts()
{
if (!$this->fp) {
echo "File pointer failed to init.";
return false;
}
$this->parser = xml_parser_create("UTF-8");
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'startXML', 'endXML');
xml_set_character_data_handler($this->parser, 'charXML');
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
$state = 0;
while (!feof($this->fp)) {
$chunk = fread($this->fp, 8192);
// read in 8KB chunks (8192 bytes)
if ($state == 0 && trim($chunk) == '') {
continue;
// scan until it reacheas something (just in case)
} elseif ($state == 0 && strpos($chunk, '<?xml') !== false) {
// the first chunk, probably includes the header(s)
$chunk = preg_replace('#<\\?xml.+?>#i', '', $chunk);
// remove the header(s) from the first chunk
$state = 1;
}
if (!xml_parse($this->parser, $chunk, feof($this->fp))) {
$this->error(sprintf('XML error at line %d column %d', xml_get_current_line_number($this->parser), xml_get_current_column_number($this->parser)) . ' -' . xml_error_string(xml_get_error_code($this->parser)));
}
}
return $this->posts;
}
开发者ID:vinothtimes,项目名称:dchqtest,代码行数:31,代码来源:SimplyHiredXMLParser.php
示例6: __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
示例7: xmlize
/**
* Create an array structure from an XML string.
*
* Usage:<br>
* <code>
* $xml = xmlize($array);
* </code>
* See the function {@link traverse_xmlize()} for information about the
* structure of the array, it's much easier to explain by showing you.
* Be aware that the array is somewhat tricky. I use xmlize all the time,
* but still need to use {@link traverse_xmlize()} quite often to show me the structure!
*
* THIS IS A PHP 5 VERSION:
*
* This modified version basically has a new optional parameter
* to specify an OUTPUT encoding. If not specified, it defaults to UTF-8.
* I recommend you to read this PHP bug. There you can see how PHP4, PHP5.0.0
* and PHP5.0.2 will handle this.
* {@link http://bugs.php.net/bug.php?id=29711}
* Ciao, Eloy :-)
*
* @param string $data The XML source to parse.
* @param int $whitespace If set to 1 allows the parser to skip "space" characters in xml document. Default is 1
* @param string $encoding Specify an OUTPUT encoding. If not specified, it defaults to UTF-8.
* @param bool $reporterrors if set to true, then a {@link xml_format_exception}
* exception will be thrown if the XML is not well-formed. Otherwise errors are ignored.
* @return array representation of the parsed XML.
*/
function xmlize($data, $whitespace = 1, $encoding = 'UTF-8', $reporterrors = false)
{
$data = trim($data);
$vals = array();
$parser = xml_parser_create($encoding);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $whitespace);
xml_parse_into_struct($parser, $data, $vals);
// Error handling when the xml file is not well-formed
if ($reporterrors) {
$errorcode = xml_get_error_code($parser);
if ($errorcode) {
$exception = new xml_format_exception(xml_error_string($errorcode), xml_get_current_line_number($parser), xml_get_current_column_number($parser));
xml_parser_free($parser);
throw $exception;
}
}
xml_parser_free($parser);
$i = 0;
if (empty($vals)) {
// XML file is invalid or empty, return false
return false;
}
$array = array();
$tagname = $vals[$i]['tag'];
if (isset($vals[$i]['attributes'])) {
$array[$tagname]['@'] = $vals[$i]['attributes'];
} else {
$array[$tagname]['@'] = array();
}
$array[$tagname]["#"] = xml_depth($vals, $i);
return $array;
}
开发者ID:evltuma,项目名称:moodle,代码行数:61,代码来源:xmlize.php
示例8: MagpieRSS
function MagpieRSS($source)
{
# if PHP xml isn't compiled in, die
#
if (!function_exists('xml_parser_create')) {
trigger_error("Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php");
}
$parser = @xml_parser_create();
if (!is_resource($parser)) {
trigger_error("Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
}
$this->parser = $parser;
# pass in parser, and a reference to this object
# set up handlers
#
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'feed_start_element', 'feed_end_element');
xml_set_character_data_handler($this->parser, 'feed_cdata');
$status = xml_parse($this->parser, $source);
if (!$status) {
$errorcode = xml_get_error_code($this->parser);
if ($errorcode != XML_ERROR_NONE) {
$xml_error = xml_error_string($errorcode);
$error_line = xml_get_current_line_number($this->parser);
$error_col = xml_get_current_column_number($this->parser);
$errormsg = "{$xml_error} at line {$error_line}, column {$error_col}";
$this->error($errormsg);
}
}
xml_parser_free($this->parser);
$this->normalize();
}
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:32,代码来源:rss.php
示例9: ParserError
function ParserError($XMLParser)
{
unset($this->arrFeedItems);
unset($this->arrItemData);
$this->arrFeedItems['error_code'] = xml_get_error_code($XMLParser);
$this->arrFeedItems['line_number'] = xml_get_current_line_number($XMLParser);
$this->arrFeedItems['column_number'] = xml_get_current_column_number($XMLParser);
}
开发者ID:benbarden,项目名称:injader,代码行数:8,代码来源:RSSParser.php
示例10: get_xml_error
/** Get the xml error if an an error in the xml file occured during parsing. */
public function get_xml_error()
{
if ($this->parse_error) {
$errCode = xml_get_error_code($this->parser);
$thisError = "Error Code [" . $errCode . "] \"<strong style='color:red;'>" . xml_error_string($errCode) . "</strong>\",\n at char " . xml_get_current_column_number($this->parser) . "\n on line " . xml_get_current_line_number($this->parser) . "";
} else {
$thisError = $this->parse_error;
}
return $thisError;
}
开发者ID:adrianro9224,项目名称:sanaquefarma.com,代码行数:11,代码来源:test.php
示例11: _parse
protected function _parse($data = '')
{
// Deprecation warning.
MLog::add('MSimpleXML::_parse() is deprecated.', MLog::WARNING, 'deprecated');
//Error handling
if (!xml_parse($this->_parser, $data)) {
$this->_handleError(xml_get_error_code($this->_parser), xml_get_current_line_number($this->_parser), xml_get_current_column_number($this->_parser));
}
//Free the parser
xml_parser_free($this->_parser);
}
开发者ID:vanie3,项目名称:appland,代码行数:11,代码来源:simplexml.php
示例12: castXml
public static function castXml($h, array $a, Stub $stub, $isNested)
{
$a['current_byte_index'] = xml_get_current_byte_index($h);
$a['current_column_number'] = xml_get_current_column_number($h);
$a['current_line_number'] = xml_get_current_line_number($h);
$a['error_code'] = xml_get_error_code($h);
if (isset(self::$xmlErrors[$a['error_code']])) {
$a['error_code'] = new ConstStub(self::$xmlErrors[$a['error_code']], $a['error_code']);
}
return $a;
}
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:11,代码来源:XmlResourceCaster.php
示例13: create
/**
* Factory XML parsing exception.
*
* @param resource $parser
* @throws static
*/
public static function create($parser)
{
if (!is_resource($parser) || 'xml' !== get_resource_type($parser)) {
$message = 'Argument #1 of "' . __CLASS__ . '::' . __METHOD__ . '" must be a resource returned by "xml_parser_create"';
throw new InvalidArgumentException($message);
}
$code = xml_get_error_code($parser);
$error = xml_error_string($code);
$line = xml_get_current_line_number($parser);
$column = xml_get_current_column_number($parser);
return new static(sprintf('XML parsing error: "%s" at Line %d at column %d', $error, $line, $column), $code);
}
开发者ID:alexivenkov,项目名称:xmppbot,代码行数:18,代码来源:XMLParserException.php
示例14: __construct
public function __construct($message, $parser, \SplFileObject $file = NULL)
{
$this->code = xml_get_error_code($parser);
if (false === $this->code) {
throw new \BadMethodCallException('This is not a valid xml_parser resource.');
}
parent::__construct($message ?: xml_error_string($this->code), $this->code);
$this->file = $file ? $file->getPathname() : '(data stream)';
$this->line = xml_get_current_line_number($parser);
$this->err['srcColumn'] = xml_get_current_column_number($parser);
$this->err['srcIndex'] = xml_get_current_byte_index($parser);
}
开发者ID:anrdaemon,项目名称:library,代码行数:12,代码来源:XmlParserError.php
示例15: Parse
function Parse($data)
{
if (!xml_parse($this->parser, $data)) {
$this->data = array();
$this->errorCode = xml_get_error_code($this->parser);
$this->errorString = xml_error_string($this->errorCode);
$this->currentLine = xml_get_current_line_number($this->parser);
$this->currentColumn = xml_get_current_column_number($this->parser);
} else {
$this->data = $this->data['child'];
}
xml_parser_free($this->parser);
}
开发者ID:Sajaki,项目名称:wowroster_dev,代码行数:13,代码来源:xmlparse.class.php
示例16: parse
function parse()
{
$parser = $this->parser;
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
// Dont mess with my cAsE sEtTings
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
// Dont bother with empty info
if (!xml_parse_into_struct($parser, $this->rawXML, $this->valueArray, $this->keyArray)) {
$this->status = 'error: ' . xml_error_string(xml_get_error_code($parser)) . ' at line ' . xml_get_current_line_number($parser) . ' at column ' . xml_get_current_column_number($parser);
return false;
}
xml_parser_free($parser);
$this->findDuplicateKeys();
// tmp array used for stacking
$stack = array();
$increment = 0;
foreach ($this->valueArray as $val) {
if ($val['type'] == "open") {
//if array key is duplicate then send in increment
if (array_key_exists($val['tag'], $this->duplicateKeys)) {
array_push($stack, $this->duplicateKeys[$val['tag']]);
$this->duplicateKeys[$val['tag']]++;
} else {
// else send in tag
array_push($stack, $val['tag']);
}
} elseif ($val['type'] == "close") {
array_pop($stack);
// reset the increment if they tag does not exists in the stack
if (array_key_exists($val['tag'], $stack)) {
$this->duplicateKeys[$val['tag']] = 0;
}
} elseif ($val['type'] == "complete") {
//if array key is duplicate then send in increment
if (array_key_exists($val['tag'], $this->duplicateKeys)) {
array_push($stack, $this->duplicateKeys[$val['tag']]);
$this->duplicateKeys[$val['tag']]++;
} else {
// else send in tag
array_push($stack, $val['tag']);
}
$this->setArrayValue($this->output, $stack, $val['value']);
array_pop($stack);
}
$increment++;
}
$this->status = 'success';
return true;
}
开发者ID:shophelfer,项目名称:shophelfer.com-shop,代码行数:49,代码来源:xmlparserv4.php
示例17: Parse
/**
* Initiates and runs PHP's XML parser
*/
public function Parse()
{
//Create the parser resource
$this->parser = xml_parser_create();
//Set the handlers
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'StartElement', 'EndElement');
xml_set_character_data_handler($this->parser, 'CharacterData');
//Error handling
if (!xml_parse($this->parser, $this->xml)) {
$this->HandleError(xml_get_error_code($this->parser), xml_get_current_line_number($this->parser), xml_get_current_column_number($this->parser));
}
//Free the parser
xml_parser_free($this->parser);
}
开发者ID:rawntech-rohan,项目名称:Project-CJ,代码行数:18,代码来源:Core_XMLParser.php
示例18: parse
function parse($url)
{
$values = "";
$encoding = 'UTF-8';
$data = file_get_contents($url);
$parser = xml_parser_create($encoding);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
$ok = xml_parse_into_struct($parser, $data, $values);
if (!$ok) {
$errmsg = sprintf("XML parse error %d '%s' at line %d, column %d (byte index %d)", xml_get_error_code($parser), xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), xml_get_current_column_number($parser), xml_get_current_byte_index($parser));
}
xml_parser_free($parser);
return $this->reorganize($values);
}
开发者ID:Nnamso,项目名称:tbox,代码行数:15,代码来源:xml.php
示例19: ExtractArrayFromXMLString
private static function ExtractArrayFromXMLString($data)
{
$xmlParser = xml_parser_create_ns('UTF-8');
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, 0);
$xmlTags = array();
$rc = xml_parse_into_struct($xmlParser, $data, $xmlTags);
if ($rc == false) {
throw new CDavXMLParsingException(xml_error_string(xml_get_error_code($xmlParser)), xml_get_current_line_number($xmlParser), xml_get_current_column_number($xmlParser));
}
xml_parser_free($xmlParser);
if (count($xmlTags) == 0) {
$xmlTags = null;
}
return $xmlTags;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:xmldocument.php
示例20: parse
function parse($data)
{
$this->parser = xml_parser_create('UTF-8');
xml_set_object($this->parser, $this);
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($this->parser, 'cdata');
if (!xml_parse($this->parser, $data)) {
$this->data = array();
$this->error_code = xml_get_error_code($this->parser);
$this->error_string = xml_error_string($this->error_code);
$this->current_line = xml_get_current_line_number($this->parser);
$this->current_column = xml_get_current_column_number($this->parser);
}
xml_parser_free($this->parser);
return $this->data;
}
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:17,代码来源:class.xml.php
注:本文中的xml_get_current_column_number函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论