Bug #55353 [Com]: XML Error in 5.3.6
| From: | anrdaemon at freemail dot ru | Date: | Mon, 15 Feb 2016 01:05:43 +0000 |
| Subject: | Bug #55353 [Com]: XML Error in 5.3.6 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199209@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55353&edit=1
ID: 55353
Comment by: anrdaemon at freemail dot ru
Reported by: pim at highattention dot nl
Summary: XML Error in 5.3.6
Status: Open
Type: Bug
Package: *XML functions
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
https://bugs.php.net/bug.php?id=55353
SIMPLEXML []
NAME []
#text: PageControl
/NAME
TITLE []
#text: Paginabeheer
/TITLE
VERSION []
#text: 1.0.0
/VERSION
CMS_ROUTES []
INDEX
{"TYPE":"default","INMENU":"true","AUTHLEVEL":"50"}
TITLE []
#text: Overzicht
/TITLE
PARTS []
PART []
#text: pagecontrol
/PART
PART []
#text: *
/PART
XML Parser error 'Mismatched tag' in (data stream):311(13,37)
Stack trace:
#0 â¦/XmlParser.php(106):
org\rootdir\Wrapper\XmlParser->parse('<simplexml>\n\t\t\t...', true)
#1 â¦/xml-test.php(200):
org\rootdir\Wrapper\XmlParser->parseString('<simplexml>\n\t\t\t...')
#2 {main}
Which is 100% expected considering the open tag is "<parts>" but closing one is
"</title>". And there's one more mismatch too:
"<cms_routes>"/"</cms>", also "</version>" closed
twice.
After fixing the three mentioned issues with provided sample, it parses perfectly.
Previous Comments:
------------------------------------------------------------------------
[2011-08-03 10:47:54] pim at highattention dot nl
<?php
function parse( $xml ){
//$this->_parserMemory = array();
$parser = xml_parser_create('UTF-8');
xml_set_object($parser, $this);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-
8');
xml_set_element_handler($parser, "_xmlTagOpen", "_xmlTagClose");
xml_set_character_data_handler($parser, "_xmlCdata");
if (!xml_parse($parser, $xml)) {
$this->_children = array();
$error_code = xml_get_error_code($parser);
$error_string = xml_error_string($error_code);
$current_line = xml_get_current_line_number($parser);
$current_column =
xml_get_current_column_number($parser);
echo ("Parser error #{$error_code}: {$error_string} on
line {$current_line}, column {$current_column}.");
}
//unset($this->_parserMemory);
xml_parser_free($parser);
}
$xml = '<simplexml>
<name>PageControl</name>
<title>Paginabeheer</title>
<version>1.0.0</version>
<cms_routes>
<index type="default"
inMenu="true" authlevel="50">
<title>Overzicht</title>
<parts>
<part>pagecontrol</part>
<part>*</part>
</title>
</index>
</cms>
</version>
</simplexml>';
parse( $xml );
?>
------------------------------------------------------------------------
[2011-08-03 10:36:51] pajoye@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2011-08-03 10:34:14] pim at highattention dot nl
Description:
------------
---
From manual page: http://www.php.net/function.xml-parse%23Description
---
We migrate from 5.2 to 5.3 and gives a error:
Parser error #73: > required on line 6, column 14.
Test script:
---------------
PHP
-----------------------------------------
$this->_parserMemory = array();
$parser = xml_parser_create('UTF-8');
xml_set_object($parser, $this);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_element_handler($parser, "_xmlTagOpen", "_xmlTagClose");
xml_set_character_data_handler($parser, "_xmlCdata");
if (!xml_parse($parser, $xml)) {
$this->_children = array();
$error_code = xml_get_error_code($parser);
$error_string = xml_error_string($error_code);
$current_line = xml_get_current_line_number($parser);
$current_column = xml_get_current_column_number($parser);
throw new Idify_FileHandler_Xml_Exception("In {$this->_filename} : Parser error
#{$error_code}: {$error_string} on line {$current_line}, column {$current_column}.");
}
unset($this->_parserMemory);
xml_parser_free($parser);
----------------------------------------
XML
----------------------------------------
<simplexml>
<name>PageControl</name>
<title>Paginabeheer</title>
<version>1.0.0</version>
<cms_routes>
<index type="default" inMenu="true" authlevel="50">
<title>Overzicht</title>
<parts>
<part>pagecontrol</part>
<part>*</part>
Expected result:
----------------
No error, system gives a new error on a attribute. Exact xml in 5.2 and 5.3, but
in 5.3, he gives a error on a attribute.
And gives a error on: <?xml version="1.0"?>, when I remove this line the error
disapear
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55353&edit=1