php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34644 Unbound prefix error when using xml_parser_create_ns
Submitted: 2005-09-26 14:37 UTC Modified: 2005-09-26 15:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: markkevans at gmail dot com Assigned:
Status: Not a bug Package: XML related
PHP Version: 4.4.0 OS: FreeBSD 5.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: markkevans at gmail dot com
New email:
PHP Version: OS:

 

 [2005-09-26 14:37 UTC] markkevans at gmail dot com
Description:
------------
When attempting to create an XML parser using xml_parser_create_ns and parsing the structure using xml_parse_into_struct an error is thrown.

My configure settings

'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--with-regex=php' '--with-apxs2=/usr/local/sbin/apxs' '--prefix=/usr/local' 'i386-portbld-freebsd5.4'

XML Support 	active
XML Namespace Support 	active
EXPAT Version 	expat_1.95.8

When running the same code on Windows XP the expected result is returned sucessfully.

Reproduce code:
---------------
<?php

$sData = "<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>";
$xml_parser = xml_parser_create_ns();

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);		
	}
		
echo "<PRE>";
print_r($aVals);
echo "</PRE>";

?>

Expected result:
----------------
Array
  (
  [0] => Array
    (
    [tag] => MY:OBJECT
    [type] => open
    [level] => 1
    [attributes] => Array
      (
      [NAME] => __root
      )

    [value] => %3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3E
   )

  [1] => Array
    (
    [tag] => MY:VARIABLE
    [type] => complete
    [level] => 2
    [attributes] => Array
      (
      [NAME] => Test
      )

    )

  [2] => Array
    (
    [tag] => MY:OBJECT
    [value] => %3C%2Ftitle%3E%0A%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A
    [type] => cdata
    [level] => 1
    )

  [3] => Array
    (
    [tag] => MY:OBJECT
    [type] => close
    [level] => 1
    )
  )

Actual result:
--------------
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 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-26 15:55 UTC] chregu@php.net
You have to declare the namespace, your xml is not valid this 
way...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC