xml_parse -> seg fault

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MarkV
Forum Newbie
Posts: 2
Joined: Mon Oct 23, 2006 2:49 pm

xml_parse -> seg fault

Post by MarkV »

Hi. I have problems with the xml extension when using xml_set_object.
Simplified script:

Code: Select all

<?php
class MyClass
{
        function startElement($parser, $name, $attribs)
        {
                if ($name=="BODY")
                {
                        echo "+"; flush();
                }
        }
        function endElement($parser, $name)
        {
                if ($name=="BODY")
                {
                        echo "-"; flush();
                }
        }
}

echo "new MyClass "; flush();
$o = new MyClass;
echo "xml_parser_create "; flush();
$parser = xml_parser_create();
echo "xml_set_element_handler "; flush();
xml_set_element_handler($parser, "startElement", "endElement");
echo "xml_set_object "; flush();
xml_set_object($parser, $o);
echo "data "; flush();
$data = "<root><body></body><body></body></root>";
echo "xml_parse "; flush();
xml_parse($parser, $data, true);
echo "xml_get_error_code "; flush();
echo xml_get_error_code($parser); flush();
?>
the output is:
new MyClass xml_parser_create xml_set_element_handler xml_set_object data xml_parse Segmentation fault
Only happens when xml_set_object is called. Without an object all is fine.
I'm using openSuSE 10.1 and php 5.1.2.
Anybody with the same issue or even better: with a solution to the problem? Hints are welcome.

TIA Mark
spasticus
Forum Newbie
Posts: 2
Joined: Mon Oct 23, 2006 4:01 pm

Post by spasticus »

my php is cr*p so you'll have to explain what you are trying to do. :oops:

ive got a script which parses xml to php - err if you want to post just ask - i thought it would best not to now incase its got nothing to do with what you want.
MarkV
Forum Newbie
Posts: 2
Joined: Mon Oct 23, 2006 2:49 pm

Post by MarkV »

I want to use the xml extension on my linux box without php going on the fritz. The same script on a windows xp pc doesn't make any trouble.
Segmentation fault - that's not an script error but php kicking the bucket.
Post Reply