[Cialug] xml

Tony Bibbs cialug@cialug.org
Mon, 22 Nov 2004 11:13:31 -0600


Do that by adding --with-xml.  Also, if you can, I'd recommend using 
PHP5 as they have xPath and DOM support. 

--Tony

Jerry Weida wrote:

>You will need to install the xml extension for php.  It is not
>installed by default.
>
>
>On Sun, 21 Nov 2004 13:50:28 -0600, ralph <kesselr1@mchsi.com> wrote:
>  
>
>>I've gotten the following error message:
>>
>>Call to undefined function:  xml_parser_create() in
>>*/home/ralph/public_html/xml9/script_09_06.php* on line *58*
>>The code is as follows:
>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>       "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
>><html xmlns="http://www.w3.org/1999/xhtml">
>><head>
>>       <title>XML Parser</title>
>></head>
>><body>
>><pre>
>><?php # parse.php (second version)
>>
>>// This script will parse an XML file, which it takes as an argument.
>>
>>// Define some constants to represent the greater than and less than symbols.
>>define ('LT', '<font color="blue">&lt;</font>');
>>define ('GT', '<font color="blue">&gt;</font>');
>>
>>// Define the functions required for handling the different pieces.
>>function handle_open_element ($p, $element, $attributes) {
>>       $element = strtolower($element);
>>       switch ($element) {
>>               case 'cover_image':
>>                       $image = @getimagesize ($attributes['FILENAME']);
>>                       echo "<img src=\"{$attributes['FILENAME']}\" $image[3] border=\"0\"><br />\n";
>>                       break;
>>               case 'song':
>>                       echo '      ' . LT . '<font color="red">' . $element . '</font>';
>>                       foreach ($attributes as $key => $value) {
>>                               echo ' <font color="green">' . strtolower($key) . '="' . $value . '"</font>';
>>                       }
>>                       echo GT;
>>                       break;
>>               case 'collection':
>>                       echo LT . '<font color="red">' . $element . '</font>' . GT . '<br />';
>>                       break;
>>               case 'album':
>>                       echo LT . '<font color="red">' . $element . '</font>' . GT . '<br />';
>>                       break;
>>               default:
>>                       echo '   ' . LT . '<font color="red">' . $element . '</font>' . GT;
>>                       break;
>>       }
>>}
>>
>>function handle_close_element ($p, $element) {
>>       $element = strtolower($element);
>>       if ($element != 'cover_image') {
>>               echo LT . '<font color="red">/' . $element . '</font>' . GT . '<br />';
>>       }
>>}
>>
>>function handle_character_data ($p, $cdata) {
>>       echo "<b>$cdata</b>";
>>}
>>
>>// End of the functions.
>>
>>// Create the parser and set the handling functions.
>>$p = xml_parser_create();
>>xml_set_element_handler ($p, 'handle_open_element', 'handle_close_element');
>>xml_set_character_data_handler ($p, 'handle_character_data');
>>
>>// Read the file.
>>$fp = @fopen ($file, 'r') or die ("Could not open a file called: $file");
>>while ($data = fread ($fp, filesize($file))) {
>>       if (!xml_parse ($p, $data, feof($fp))) {
>>               printf("An XML error occurred on line %d: %s.", xml_get_current_line_number($p), xml_error_string(xml_get_error_code($p)));
>>       }
>>}
>>
>>// Free up the parser.
>>xml_parser_free($p);
>>?>
>></pre>
>></body>
>></html>
>>I've googled all over the place to find why Mandrake 10 doesn't support xml with PHP and can't seem to find the answer.
>>Could someone suggest an answer?
>>Thanks
>>
>>_______________________________________________
>>Cialug mailing list
>>Cialug@cialug.org
>>http://cialug.org/mailman/listinfo/cialug
>>
>>    
>>
>_______________________________________________
>Cialug mailing list
>Cialug@cialug.org
>http://cialug.org/mailman/listinfo/cialug
>  
>