Strange issue with xml_parse_into_struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All

I am having an issue when trying to parse an xml document with namespaces.

The XML data I am trying to parse looks like the following

<my:object name="__root">%3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3E<my:variable
name='Test'/>%3C%2Ftitle%3E%0A%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A</my:object>

A small script to reproduce the problem I am having is as follows (note:
This isnt pretty I know ;-))

<?php
$sFile = "data.xml";
$xml_parser = xml_parser_create_ns();

if (!($pFile = fopen($sFile, "r")))
 {
   die("could not open XML input");
 }

$sData = fread($pFile, filesize($sFile));
fclose($pFile);

if (!xml_parse_into_struct($xml_parser, $sData, $aVals, $aIndex))
 {
 $nErrorCode = xml_get_error_code($xml_parser);
 $sError = xml_error_string($nErrorCode);
 $sErrorMessage = 'XML Parser Error: Error Code: ' . $nErrorCode . ' Error
String: ' . $sError . ' Line Number: ' .
xml_get_current_line_number($xml_parser);
 trigger_error($sErrorMessage, E_USER_WARNING);
 }
?>

This script works perfectly on all versions of PHP on Windows.. however as soon as I test this on a FreeBSD box running 4.4.0 or a CentOS box running 4.3.9 I get the same error

Warning: XML Parser Error: Error Code: 27 Error String: unbound prefix Line Number: 1 in /usr/local/www/data-dist/xml/test.php on line 18

If I change

$xml_parser = xml_parser_create_ns();

to

$xml_parser = xml_parser_create();

It does work on both platforms.

The question is (finally ;-)) can anyone see anything wrong with what I am trying to do? Is there an issue in xml_parse_into_struct when used with xml_parser_create_ns on non-windows platforms (the latter I dobut as I have searched the php bugs section and havent found anything relating to this).

TIA

Mark

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux