Bug #6671 Updated: using the XML parser in a class does not seem to work any longer
| From: | sniper@php.net | Date: | Tue, 18 Jun 2002 22:13:46 +0000 |
| Subject: | Bug #6671 Updated: using the XML parser in a class does not seem to work any longer | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-11212@lists.php.net to get a copy of this message | ||
ID: 6671
Updated by: sniper@php.net
Reported By: d.roche@lectra.com
-Status: Duplicate
+Status: Closed
Bug Type: XML related
Operating System: Linux RedHat 6.2
PHP Version: 4.0.2
New Comment:
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
Previous Comments:
------------------------------------------------------------------------
[2001-05-07 16:11:24] cardinal@php.net
This looks like a dup of 6175.
------------------------------------------------------------------------
[2000-10-30 09:43:37] stas@php.net
tim.diggins@teamworks.co.uk also reports this to happen in:
PHP 4.0.2 running as ISAPI under Win98/ed1/PWS
RH6.2 and apache [various versions]
------------------------------------------------------------------------
[2000-09-12 02:05:38] d.roche@lectra.com
here is a little script which works with php4.0.1pl2
and crash ( Segmentation fault (11) ) with php4.0.2 !
both version where compiled with :
./configure --disable-debug --with-apxs=/usr/sbin/apxs
--with-regex=system --with-zlib --with-gd --with-db2 --with-gdbm
--with-config-file-path=/etc/httpd --enable-trans-sid
the php.ini is the same for both.
========script : cut here================
<head>
<title>test xml problem</title>
</head>
<body>
<h1>test xml problem</h1>
<pre>
<script language="php">
class XmlParse {
// variable members
var $parser;
//***********************************************************
// constructor
function XmlParse() {
$this->parser = xml_parser_create();
xml_set_object($this->parser,&$this);
xml_set_element_handler($this->parser,"tag_open","tag_close");
xml_set_character_data_handler($this->parser,"core_data");
}
//***********************************************************
// handler (private) functions
function tag_open($parser,$tag,$attributes) {
$this->debug1("tag_open",$tag.$this->viewarray($attributes));
}
function tag_close($parser,$tag) {
$this->debug1("tag_close",$tag);
}
function core_data($parser,$cdata) {
$this->debug1("core_data",$cdata);
}
//***********************************************************
// parse (public) function
function parse($data) {
if (!xml_parse($this->parser, $data, 1)) {
$error = sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->parser)),
xml_get_current_line_number($this->parser));
echo $error;
}
xml_parser_free($this->parser);
}
//***********************************************************
// debug function
function debug1($title,$msg) {
echo $title;
echo " «";
echo $msg;
echo "» ";
echo "\n";
}
function viewarray($arr) {
$str = "";
if ( is_array($arr) ) {
while ( list($key,$val) = each($arr) ) {
$str .= " ".$key."=".$val;
}
}
return $str;
}
}
$xmldata = '<?xml version="1.0"?><tab><line><auteur>zimmer
bradley</auteur><titre>la matrice fantôme</titre><serie>la romance de
ténébreuse</serie><type>ser20</type><moyenne>16</moyenne><genre>0x00000004</genre><key>0000658</key></line></tab>';
$xfx = new XmlParse();
$xfx->parse($xmldata);
</script>
</pre>
</body>
==========cut here================
Some other tests i have made shows that XML parsing works well
with standard functions but does not work any longer with class
methods.
I use xml_set_object($this->parser,&$this);
thank you for your attention !
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=6671&edit=1